From e@REDACTED Sun Feb 1 02:08:49 2015 From: e@REDACTED (e@REDACTED) Date: Sun, 01 Feb 2015 02:08:49 +0100 Subject: [erlang-questions] SSL: "unknown ca" In-Reply-To: <54CD4EB7.4080605@wanadoo.fr> References: <3h1xqxrq1xeoikq5qoulydau.1422728755306@email.android.com> <54CD1EC8.2040104@ninenines.eu> <54CD1F9D.7000707@bestmx.net> <54CD206A.6060607@ninenines.eu> <54CD20CA.3030509@bestmx.net> <126074499.136820.1422736581055.JavaMail.open-xchange@oxbaltgw35.schlund.de> <54CD4163.2020802@bestmx.net> <54CD45B4.9070205@bestmx.net> <54CD47FD.1070601@wanadoo.fr> <54CD48B7.2070100@wanadoo.fr> <54CD4B6D.20104@bestmx.net> <54CD4EB7.4080605@wanadoo.fr> Message-ID: <54CD7CA1.5030604@bestmx.net> On 01/31/2015 10:52 PM, PAILLEAU Eric wrote: > You are mixing OSI layers. no i do not (you simply forget that we operate in real world where "changing protocol" does not mean changing the protocol but changing the software which potentially behave god-knows how much different way) > If the SSL handshake fails, there is nothing to do with the protocol > that want to go into the SSL tunnel. since no one of us knows the exact interpretation of the error message, i am experimenting with a BLACK BOX. changing the protocol is just another "irritant" which may or may not yield us some info -- preaching RFCs may not for sure. From r.wobben@REDACTED Sun Feb 1 11:14:49 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Sun, 01 Feb 2015 11:14:49 +0100 Subject: [erlang-questions] concentate solution well ?? Message-ID: <54CDFC99.5000900@home.nl> Hello, I have this exercise of the Erlang programming book. Write a function that, given a list of lists, will concatenate them. Example: concatenate([[1,2,3], [], [4, five]]) ? [1,2,3,4,five]. Hint: you will have to use a helpfunction and concatenate the lists in several steps. But I do not need to use a helper function because it can be solved like this : concatenate( [List1 , List2 , List3] ) -> List1 ++ List2 ++ List3. Or is this not the solution that is meant on this exercise ? Do I need to solve it by using pattern matching ? Roelof From bob@REDACTED Sun Feb 1 11:24:38 2015 From: bob@REDACTED (Bob Ippolito) Date: Sun, 1 Feb 2015 02:24:38 -0800 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CDFC99.5000900@home.nl> References: <54CDFC99.5000900@home.nl> Message-ID: The goal is to solve the problem as stated such that it would work for *any* example, not just that one. It's very easy to come up with an example that does not work with your implementation. Perhaps you should read the source for the lists module, and take the time to try and understand it. https://github.com/erlang/otp/blob/maint/lib/stdlib/src/lists.erl On Sun, Feb 1, 2015 at 2:14 AM, Roelof Wobben wrote: > Hello, > > I have this exercise of the Erlang programming book. > > Write a function that, given a list of lists, will concatenate them. > Example: > concatenate([[1,2,3], [], [4, five]]) ? [1,2,3,4,five]. > Hint: you will have to use a helpfunction and concatenate the lists in > several steps. > > But I do not need to use a helper function because it can be solved like > this : > > concatenate( [List1 , List2 , List3] ) -> > List1 ++ List2 ++ List3. > > Or is this not the solution that is meant on this exercise ? > Do I need to solve it by using pattern matching ? > > Roelof > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben@REDACTED Sun Feb 1 12:08:11 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Sun, 01 Feb 2015 12:08:11 +0100 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: References: <54CDFC99.5000900@home.nl> Message-ID: <54CE091B.2070301@home.nl> An HTML attachment was scrubbed... URL: From gfborn@REDACTED Sun Feb 1 13:24:50 2015 From: gfborn@REDACTED (Grigory Fateyev) Date: Sun, 1 Feb 2015 15:24:50 +0300 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CE091B.2070301@home.nl> References: <54CDFC99.5000900@home.nl> <54CE091B.2070301@home.nl> Message-ID: <20150201152450.09d167d7@gmail.com> Hello Roelof Wobben! On Sun, 01 Feb 2015 12:08:11 +0100 you wrote: > Bob Ippolito schreef op 1-2-2015 om 11:24: > The goal is to solve the problem as stated such that it would work > for *any* example, not just that one. It's very easy to come up with > an example that does not work with your implementation. > > Perhaps you should read the source for the lists module, and take the > time to try and understand > it.?https://github.com/erlang/otp/blob/maint/lib/stdlib/src/lists.erl > > On Sun, Feb 1, 2015 at 2:14 AM, Roelof Wobben > wrote: Hello, > > I have this exercise of the Erlang programming book. > > Write a function that, given a list of lists, will concatenate them. > Example: > concatenate([[1,2,3], [], [4, five]]) ? [1,2,3,4,five]. > Hint: you will have to use a helpfunction and concatenate the lists > in several steps. > > But I do not need to use a helper function because it can be solved > like this : > > concatenate( [List1 , List2 , List3] ) -> > ? ? List1 ++ List2 ++ List3. > > Or is this not the solution that is meant on this exercise ? > Do I need to solve it by using pattern matching ? I think it can be solved by recursion. -- Best regards! gfborn [at] gmail [dot] com From roberto@REDACTED Sun Feb 1 16:12:57 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Sun, 1 Feb 2015 16:12:57 +0100 Subject: [erlang-questions] Return value: optimization? Message-ID: Dear list, I was going through cowboy's code and I keep on seeing patterns such as this: _ = cowboy_req:reply(Status, Req), [1] or this one: _ = case TRef of undefined -> ignore; TRef -> erlang:cancel_timer(TRef) end, [2] All of these are done when we're there's no tail recursion. So now I'm curious: what is the purpose of explicitly assigning an anonymous variable to these expressions? Is this some kind of memory optimisation I'm just now aware of? Best, r. [1] https://github.com/ninenines/cowboy/blob/1.0.1/src/cowboy_protocol.erl#L504 [2] https://github.com/ninenines/cowboy/blob/1.0.1/src/cowboy_handler.erl#L274 -------------- next part -------------- An HTML attachment was scrubbed... URL: From essen@REDACTED Sun Feb 1 16:37:38 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Sun, 01 Feb 2015 16:37:38 +0100 Subject: [erlang-questions] Return value: optimization? In-Reply-To: References: Message-ID: <54CE4842.2060009@ninenines.eu> It's to inform Dialyzer that yes, we really do want to ignore the returned value. Should have no impact on execution otherwise. On 02/01/2015 04:12 PM, Roberto Ostinelli wrote: > Dear list, > I was going through cowboy's code and I keep on seeing patterns such as > this: > > _ = cowboy_req:reply(Status, Req), [1] > > or this one: > > _ = case TRef of > undefined -> ignore; > TRef -> erlang:cancel_timer(TRef) > end, [2] > > All of these are done when we're there's no tail recursion. So now I'm > curious: what is the purpose of explicitly assigning an anonymous > variable to these expressions? Is this some kind of memory optimisation > I'm just now aware of? > > Best, > r. > > > [1] > https://github.com/ninenines/cowboy/blob/1.0.1/src/cowboy_protocol.erl#L504 > [2] > https://github.com/ninenines/cowboy/blob/1.0.1/src/cowboy_handler.erl#L274 > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Lo?c Hoguin http://ninenines.eu From roberto@REDACTED Sun Feb 1 16:46:37 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Sun, 1 Feb 2015 16:46:37 +0100 Subject: [erlang-questions] Return value: optimization? In-Reply-To: <54CE4842.2060009@ninenines.eu> References: <54CE4842.2060009@ninenines.eu> Message-ID: There you go ^^_ Thanks, r. On Sun, Feb 1, 2015 at 4:37 PM, Lo?c Hoguin wrote: > It's to inform Dialyzer that yes, we really do want to ignore the returned > value. Should have no impact on execution otherwise. > > > On 02/01/2015 04:12 PM, Roberto Ostinelli wrote: > >> Dear list, >> I was going through cowboy's code and I keep on seeing patterns such as >> this: >> >> _ = cowboy_req:reply(Status, Req), [1] >> >> or this one: >> >> _ = case TRef of >> undefined -> ignore; >> TRef -> erlang:cancel_timer(TRef) >> end, [2] >> >> All of these are done when we're there's no tail recursion. So now I'm >> curious: what is the purpose of explicitly assigning an anonymous >> variable to these expressions? Is this some kind of memory optimisation >> I'm just now aware of? >> >> Best, >> r. >> >> >> [1] >> https://github.com/ninenines/cowboy/blob/1.0.1/src/cowboy_ >> protocol.erl#L504 >> [2] >> https://github.com/ninenines/cowboy/blob/1.0.1/src/cowboy_ >> handler.erl#L274 >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -- > Lo?c Hoguin > http://ninenines.eu > -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben@REDACTED Sun Feb 1 18:27:09 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Sun, 01 Feb 2015 18:27:09 +0100 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CE091B.2070301@home.nl> References: <54CDFC99.5000900@home.nl> <54CE091B.2070301@home.nl> Message-ID: <54CE61ED.20105@home.nl> An HTML attachment was scrubbed... URL: From ingela.andin@REDACTED Sun Feb 1 19:04:35 2015 From: ingela.andin@REDACTED (Ingela Andin) Date: Sun, 1 Feb 2015 19:04:35 +0100 Subject: [erlang-questions] SSL: "unknown ca" In-Reply-To: <54CBEB9F.1080405@bestmx.net> References: <54CBCCB6.8020602@bestmx.net> <54CBEB9F.1080405@bestmx.net> Message-ID: Hi! 2015-01-30 21:37 GMT+01:00 e@REDACTED : > On 01/30/2015 09:18 PM, Ingela Andin wrote: > >> Hi! >> >> 2015-01-30 19:25 GMT+01:00 e@REDACTED : >> >> Hi, all. >>> >>> SSL: certify: ssl_alert.erl:92:Fatal error: unknown ca >>> >>> I know this issue generates thousands of "hits" in google-search >>> yet google does not reveal a consistent explanation (not a recipe!) >>> >>> first of all: Unknown TO WHOM??? >>> >>> >> >> To the client or server trying to verify its peer certificate. >> > > since the error appears on the server side, > may i deduce that the server (Erlang's ssl application) > is trying to verify the client (a browser)? > > No, the error does not appear on the server side. The error appers on the client side that sends a TLS alert message to the server side that will log the reason why the client disconnects. > in this case i want to know how to disable this feature. > (i only need to verify the server by the client) You did not enable client certification. > secondly: What CA will be considered known? >>> >>> >>> The root CA must be present in the verifiers CA database (cacertfile or >> corresponding option for that client/server). >> > > my 'cacertfile' (as given to the 'ssl' application) contains one and only > one certificate which is self-signed. > > what properties of CA are required? >>> may we assume that "CA" and "a certificate file" are synonyms in the >>> current context? otherwise, what is CA and how is it represented? >>> >> > Certificates and CA certificates are defined in RFC 5280. The are defined >> by as ASN-1 specifications and can normaly be inputed as ASN-1 DER (binary >> format) or >> as a PEM file (a text file representaion of the "DER-blob"). >> > > I was asking something else. > When 'ssl' application complains about a "CA" does it mean a corresponding > certfile that represents a CA or something else? > (Does it consider any other data sources besides those files provided by > me?) > > > No, but you are not doing client certification verification as you did not enable it. Regards Ingela Erlang/OTP team - Ericsson AB -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Sun Feb 1 19:27:57 2015 From: bob@REDACTED (Bob Ippolito) Date: Sun, 1 Feb 2015 10:27:57 -0800 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CE091B.2070301@home.nl> References: <54CDFC99.5000900@home.nl> <54CE091B.2070301@home.nl> Message-ID: On Sun, Feb 1, 2015 at 3:08 AM, Roelof Wobben wrote: > Bob Ippolito schreef op 1-2-2015 om 11:24: > > The goal is to solve the problem as stated such that it would work for > *any* example, not just that one. It's very easy to come up with an example > that does not work with your implementation. > > Perhaps you should read the source for the lists module, and take the > time to try and understand it. > https://github.com/erlang/otp/blob/maint/lib/stdlib/src/lists.erl > > On Sun, Feb 1, 2015 at 2:14 AM, Roelof Wobben wrote: > >> Hello, >> >> I have this exercise of the Erlang programming book. >> >> Write a function that, given a list of lists, will concatenate them. >> Example: >> concatenate([[1,2,3], [], [4, five]]) ? [1,2,3,4,five]. >> Hint: you will have to use a helpfunction and concatenate the lists in >> several steps. >> >> But I do not need to use a helper function because it can be solved like >> this : >> >> concatenate( [List1 , List2 , List3] ) -> >> List1 ++ List2 ++ List3. >> >> Or is this not the solution that is meant on this exercise ? >> Do I need to solve it by using pattern matching ? >> >> Roelof >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > Thanks, I will do this, > > But there is one problem. > > The source is full of -spec and in programming erlang that is explained in > chapter 18 where Im trying exercises of chapter 3. > Well, just ignore the -spec annotations. They are essentially structured documentation, they don't change the behavior of the program. -------------- next part -------------- An HTML attachment was scrubbed... URL: From e@REDACTED Sun Feb 1 19:30:15 2015 From: e@REDACTED (e@REDACTED) Date: Sun, 01 Feb 2015 19:30:15 +0100 Subject: [erlang-questions] SSL: "unknown ca" In-Reply-To: References: <54CBCCB6.8020602@bestmx.net> <54CBEB9F.1080405@bestmx.net> Message-ID: <54CE70B7.2080401@bestmx.net> > No, the error does not appear on the server side. The error appers on the > client side that sends > a TLS alert message to the server side that will log the reason why the > client disconnects. finally! we have determined the source of the error. thnx. will fix the browser, then. From bob@REDACTED Sun Feb 1 19:37:57 2015 From: bob@REDACTED (Bob Ippolito) Date: Sun, 1 Feb 2015 10:37:57 -0800 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CE61ED.20105@home.nl> References: <54CDFC99.5000900@home.nl> <54CE091B.2070301@home.nl> <54CE61ED.20105@home.nl> Message-ID: You should be able to make that assessment yourself. Does this program compile? Does it work for the example? Does it work for other examples you can come up with? On Sun, Feb 1, 2015 at 9:27 AM, Roelof Wobben wrote: > Roelof Wobben schreef op 1-2-2015 om 12:08: > > Bob Ippolito schreef op 1-2-2015 om 11:24: > > The goal is to solve the problem as stated such that it would work for > *any* example, not just that one. It's very easy to come up with an example > that does not work with your implementation. > > Perhaps you should read the source for the lists module, and take the > time to try and understand it. > https://github.com/erlang/otp/blob/maint/lib/stdlib/src/lists.erl > > On Sun, Feb 1, 2015 at 2:14 AM, Roelof Wobben wrote: > >> Hello, >> >> I have this exercise of the Erlang programming book. >> >> Write a function that, given a list of lists, will concatenate them. >> Example: >> concatenate([[1,2,3], [], [4, five]]) ? [1,2,3,4,five]. >> Hint: you will have to use a helpfunction and concatenate the lists in >> several steps. >> >> But I do not need to use a helper function because it can be solved like >> this : >> >> concatenate( [List1 , List2 , List3] ) -> >> List1 ++ List2 ++ List3. >> >> Or is this not the solution that is meant on this exercise ? >> Do I need to solve it by using pattern matching ? >> >> Roelof >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > Thanks, I will do this, > > But there is one problem. > > The source is full of -spec and in programming erlang that is explained in > chapter 18 where Im trying exercises of chapter 3. > > Roelof > > > > _______________________________________________ > erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions > > > > This solution better ? > > concatenate([]) -> > []. > > concatenate([List] ) -> > concatenate2(List1, []). > > concatenate2([], List) -> > List; > > concatenate2([Head| Tail], List) -> > concatenate2(Tail, [Head | List]) > > Roelof > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon Feb 2 01:40:36 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 2 Feb 2015 13:40:36 +1300 Subject: [erlang-questions] array search problem In-Reply-To: <54CBB304.2030103@home.nl> References: <54CBB304.2030103@home.nl> Message-ID: <01644EE8-488D-40F8-8B22-2F13CD3115A9@cs.otago.ac.nz> On 31/01/2015, at 5:36 am, Roelof Wobben wrote: > Hello, > > Im still struggeling to make the database exercise working. > > I have to implement a read method which outputs as this : > > 5> db:read(francesco, Db2). > {ok,london} > 6> Db3 = db:write(joern, stockholm, Db2). > [{joern,stockholm},{lelle,stockholm},{francesco,london}] > 7> db:read(ola, Db3). > {error,instance} > > To achieve this do I need to use a try catch or can I achieve this with only pattern matching. What on earth would you use a try-catch *for*? Your so-called "data base" is a thing that has been known as an "association list" at least since the "Lisp 1.5 programmer's manual" came out in 1962. Think about a CASE ANALYSIS. read(Key, Association_List) There is no useful case analysis to do on Key. It could be anything. Association_List could be empty or it could be non-empty. So read(Key, [Head|Tail]) -> ?What goes here?; read(Key, []) -> ?What goes here?. Let's take the empty case first. Example 7> shows that the result should be {error,instance}. I am a little surprised that the error term does not include the Key being sought. Since we're not going to use the Key in that case, I'll tell the compiler that we *mean* not to use it by prefixing "_". read(_, []) -> {error,instance}. Now let's take the non-empty case. If we know that the association list is not empty, do we know enough yet to decide what to do? No, we don't. There are going to be two sub-cases. - We have found what we are looking for. - We haven't. Do we know enough to handle example 5> ? No: we need to know that Head is a pair with Key as its first element. Some functional languages have what's called "linear" patterns, where the head of a function may mention a variable at most once, so that in Haskell we would have to write read key ((k,v):alist) | k == key = ... ^^^^^^^^^^ the guard. Erlang doesn't have that restriction. So we can do read(Key, [{Key,Value}|_]) -> % non-empty case, subcase 'found' ?what goes here?; read(Key, [_|Association_List]) -> % non-empty case, subcase 'not found' ?what goes here?; read(_Key, []) -> {error,instance}. Now the 'found' subcase will have to return {ok,Value}, and the 'not found' subcase will have to keep on looking. I'm sure you can figure those out for yourself. You might actually find the book "The Little Schemer" of use. The syntax of Scheme is very different from Erlang, and it doesn't use pattern matching, but the data structures are quite similar, in particular the lists. The book is all about teaching recursive programming, mostly using lists. From Douglas Crockford's review http://www.crockford.com/javascript/little.html Despite its flaws, the book has a very loyal following and that is because it works. It teaches one thing, a thing that is very difficult to teach, a thing that every professional programmer should know, and it does it really well. These are lessons that stick with you. You need to grab a sandwich and study this book. What is the secret of functional programming? It is case analysis, case analysis, case analysis! Cui comparatus indecens erit pavo, Inamabilis sciurus, et frequens Phoenix. --- Martial., l. 5. Epig. 38. Compared with try-catch, a phoenix should be too frequent. From ok@REDACTED Mon Feb 2 01:49:14 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 2 Feb 2015 13:49:14 +1300 Subject: [erlang-questions] array search problem In-Reply-To: <54CBCEC2.5080707@home.nl> References: <54CBB304.2030103@home.nl> <20150130171107.GD90397@ferdair.local> <54CBCEC2.5080707@home.nl> Message-ID: On 31/01/2015, at 7:34 am, Roelof Wobben wrote: > Hello, > > Im stuck again, > > I have now this : > > read(Key, []) -> > {error, Instance}; > > read(Key, [Key, _] )-> > Key; > This clause is clearly wrong. You are looking for a LIST of ONE OR MORE elements, the first of whose elements is a TUPLE of exactly two elements, the first of which is Key. But here you check for a list of exactly two elements, the first of which is Key. read(Key, [{Key,Value}|_]) -> .... The result you have here is clearly wrong given the example you previously quoted. The result is supposed to be a TUPLE of exactly two elements, the first of which is the atom 'ok' and the second of which is the value you are looking for. > read(Key, [_, Tail] ) -> > read(Key, Tail). This clause is also clearly wrong. You are looking for a list of at least one element where you don't care what the first element is. But you are checking for a list of exactly two elements. That is, you have [_,Tail] where you should have [_|Tail]. ^ ^ Maybe it would help if you started by writing down in words exactly what you wanted to match, and then wrote the pattern from the outside in, drawing lines to connect the words to the code. Also, don't be afraid to break it down into really small steps. It is OK to make just one decision per pattern, like this: read(Key, [Head|Tail]) -> read_non_empty(Key, Head, Tail); read(Key, []) -> read_empty(Key). read_empty(_) -> {error,instance}. read_non_empty(Key, {K,V}, Tail) -> read_non_empty(Key, K, V, Tail). % In order to pacify Joe Armstrong, we know have code that % will crash if it meets a list element that is not a pair. read_non_empty(Key, Key, Value, _) -> ?what goes here since we have found what we seek?; read_non_empty(Key, _, _, Rest) -> ?what goes here since we must keep looking?. Maybe you will find it easier to do one step at a time like this. From ok@REDACTED Mon Feb 2 02:45:06 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 2 Feb 2015 14:45:06 +1300 Subject: [erlang-questions] wierd outome on my match method In-Reply-To: <54CCE747.8040804@home.nl> References: <54CCE2AD.8090804@home.nl> <54CCE557.5090804@ninenines.eu> <54CCE747.8040804@home.nl> Message-ID: <0A0E3FA0-FA05-4F9E-9597-2A3FACB09561@cs.otago.ac.nz> On 1/02/2015, at 3:31 am, Roelof Wobben wrote: > Thanks, > > Everything is working now. > Finnaly I have solved the whole exercise like this : Where are the comments? For every file you write, you want a header something like this: %%% What: db.erl %%% Who : Roelof Wobben' %%% When: 2015-02-01 %%% Why : Solving $exercise on page $page in $book. When you learn about EDoc markup, you might switch over to that style, or you might prefer to use -attributes. > > -module(db). > > -export([new/0, destroy/1, write/3, read/2, delete_key/3, delete/2, match/2, match_key/3]). A personal suggestion here: lay out the functors one per line in some useful order. My preference is for alphabetic order. So -export([ delete/2, delete_key/3, destroy/1, match/2, match_key/3, new/0, read/2, write/3 ]). That way when you are looking to see if something is exported, you can just scan your eye down, keeping focus on the same column, and you can instantly tell when you have gone past what you are looking for. > new() -> > []. > This does not make a new anything. It returns an empty list, but just like the number 0, the empty list always exists. > destroy(_Db) -> > ok. This does not destroy anything. It does nothing but waste time. Even if an exercise tells you to do something pointless, YOU should have a comment that shows that YOU know it is pointless. > > write(Key, Element, Db) -> > [ {Key, Element} | Db ]. I have pointed out previously that this is ONLY tolerable when you know that you are adding a key not already in the list. YOU need to make this clear in a comment. > read(_Key, []) -> > {error, "Instance"}; > > read(Key, [Head | List]) -> > case element(1, Head) of > Key -> {ok, element(2, Head)}; > _ -> read(Key, List) > end. This is clumsy. You have switched from saying "Db" to saying "List", for no apparent reason. It will be perfectly happy with triples; if that's what you _want_, then this makes sense, but if you _want_ to accept only pairs, that's what you should match for. Better as read(Key, [{K,V}|Db]) -> case K of Key -> {ok,V} ; _ -> read(Key, Db) end. By the way, since commas and semicolons can be hard to tell apart, and since commas go at the end of lines, I *strongly* suggest NOT putting semicolons at the end of lines except for function clauses. > > delete_key( _Key, [] , List2) -> > List2 ; > > delete_key( Key, [Head | Tail], List3 ) -> > case element(1, Head) of > Key -> delete_key(Key, Tail, List3 ); > _ -> delete_key(Key, Tail, [Head | List3] ) > end. delete_key(Key, Db1, Db2) = lists:reverse( [X || X <- Db1, if element(1, Head) =:= Key -> true ; _ -> false end]) ++ Db2. Now this is particularly nasty, so I wonder if you really meant that reversal to happen. Suppose we start with [] add x -> 1 [{x,1}] add x -> 2 [{x,2},{x,1}] add y -> 3 [{y,3},{x,2},{x,1}] add y -> 4 [{y,4},{y,3},{x,2},{x,1}] call that Db0. At this point, read(x, Db0) -> 2, read(y, Db0) -> 4. delete_key(x, Db0, []) call that Db1 = [{y,3},{y,4}]. Now read(y, Db0) -> 3, instead of 4. Deleting the value(s) for x has *changed the result returned for an unrelated key*. Do you really want that? I strongly suspect that delete_key/3 should not be exported at all, that it was meant to be a building block for delete/2. > > delete( _Key, [] ) -> > {error, "Instance"}; > > delete(Key, List) -> > match_key (Key, List, []). Surely this was meant to call delete_key(Key, List, []). Also, there appears to be a problem. Working with Db0 from the previous example, delete(z, []) -> error delete(z, Db0) -> Db0. That is, deleting a key that is not present will result in an error message if and only if there are NO keys. It is hard to believe that this was intentional. Here's something that - does not change the order of the pairs in the list; - keeps track of whether it has found a matching key or not; - reports an error if and only if the key was not found, no matter how many keys *were* found. delete(Key, Db) -> delete(Key, Db, not_found). delete(Key, [{Key,_}|Db], _) -> delete(Key, Db, found); delete(Key, [Pair = {_,_}|Db], Found) -> [Pair | delete(Key, Db, Found)]; delete(_, [], found) -> []; delete(_, [], not_found) -> {error,"Instance"}. > > match_key( _Key, [] , List) -> > List ; > > match_key( Key, [Head | Tail], List ) -> > case element(1, Head) of > Key -> match_key(Key, Tail, [element(2,Head) | List] ); > _ -> match_key(Key, Tail, List ) > end. This is match_key(Key, Db1, Db2) -> lists:reverse( [element(2,X) || X <- Db1, if element(1,X) =:= Key -> true ; _ -> false end]) ++ Db2. and it is difficult to believe that the reversal is desired. > > match( Key, [] ) -> > {error, "Instance"}; > > match(Key, List) -> > match_key (Key, List, []). Once again, this will report a missing key if and only if there are NO keys. match(Key, Db) -> match(Key, Db, not_found). match(Key, [{Key,Value}|Db], _) -> [Value | match(Key, Db, found)]; match(Key, [{_,_}|Db], Found) -> match(Key, Db, Found); match(_Key, [], found) -> []; match(_Key, [], not_found) -> {error,"Instance"}. HOWEVER, reporting a missing key AT ALL in this function, EVER, seems like a bad idea. Why? Because if we care, we can *tell* because the answer is an empty list, but if we *don't* care, we have to work extra hard to cope. In the same way, I don't really see the point in complaining if you are asked to delete a key and it isn't there. A data base without that particular key? Isn't that what you _want_ when you call delete/2? > > > Now I have 2 questions : > > 1) Is this a good solution. No. > 2) Can I somewhere hide my helper functions (match_key, delete_key) and do not get a warning about unused. Yes. You "hide" a helper function by NOT EXPORTING IT. That's all. The way to not get a warning about a function being unused is to USE IT. Or if you don't have a use for it, remove it. If the Erlang compiler tells you a function is unused, then either (1) the place or places where it *is* used has or have been obliterated by syntax errors and if you fix those the compiler will notice the uses, or (2) the compiler is RIGHT. From ok@REDACTED Mon Feb 2 02:54:42 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 2 Feb 2015 14:54:42 +1300 Subject: [erlang-questions] wierd outome on my match method In-Reply-To: <54CD0271.8000806@home.nl> References: <54CCE2AD.8090804@home.nl> <54CCE557.5090804@ninenines.eu> <54CCE747.8040804@home.nl> <54CD0271.8000806@home.nl> Message-ID: <1E90ED37-C16F-4718-B1A4-EEDB38B02D0E@cs.otago.ac.nz> On 1/02/2015, at 5:27 am, Roelof Wobben wrote: > > I do not have made any test because that topic is still not covered in chapter 2 and 3 of the programming erlang book. There are special testing tools for Erlang, but at this stage, you do not need them, and the book has not mentioned testing in Erlang for the simple reason that there is nothing Erlang-SPECIFIC to say. A test case is just a function where you know what is supposed to happen and can tell if it did or not. The simplest approach is to write a module db_test with a bunch of functions called t1, t2, ... or whatever you please. These functions can be called from the Erlang shell: % erl 1> c(db). % load implementation 2> c(db_test). % load tests. 3> db_test:t1(). % try test 1 ... For example, you might have t1() -> Db0 = db:new(), {error,_} = db:read(x, Db0), % new() is empty Db1 = db:write(x, 1, Db0), {ok,1} = db:read(x, Db1), % can read what we wrote {error,_} = db:read(y, Db1), % no hallucinations Db2 = db:write(x, 2, Db1), {ok,2} = db:read(x, Db2), % write() overwrites Db2 = delete(y, Db2). % no delete => no change The name given here does not matter, as long as it's exported. The Test-Driven Development people say that it's a good idea to write the tests BEFORE you write the implementation. And along the way, in your messages, you have actually written several test cases, you just haven't put them as functions in a file where it's easy to run them again. From ok@REDACTED Mon Feb 2 03:09:32 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 2 Feb 2015 15:09:32 +1300 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CDFC99.5000900@home.nl> References: <54CDFC99.5000900@home.nl> Message-ID: <3D60A461-B028-4168-BEF0-562B747D5536@cs.otago.ac.nz> On 1/02/2015, at 11:14 pm, Roelof Wobben wrote: > Hello, > > I have this exercise of the Erlang programming book. > > Write a function that, given a list of lists, will concatenate them. > Example: > concatenate([[1,2,3], [], [4, five]]) ? [1,2,3,4,five]. > Hint: you will have to use a helpfunction and concatenate the lists in several steps. > > But I do not need to use a helper function because it can be solved like this : > > concatenate( [List1 , List2 , List3] ) -> > List1 ++ List2 ++ List3. OK, so that works for a list of THREE lists. What are you going to do if the list has THIRTY THOUSAND elements? Or if it might be *ANY* number of elements -- which is the usual point of having a list. You will not in fact need a helper function; you can use the built-in ++ operator. So, using Haskell syntax to give you *something* to do: concatenate [] = ?what? concatenate (list : list_of_lists) = ?how will you concatenate the list_of_lists? ?how will you combine the result of that with the first list? Given the pieces list : list(T) list_of_lists : list(list(T)) concatenate (list(list(T)) -> list(T)) ++ : list(T) , list(T) -> list(T) there is only one way to put them together that makes sense, so this should not be hard. From ok@REDACTED Mon Feb 2 03:25:27 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 2 Feb 2015 15:25:27 +1300 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CE61ED.20105@home.nl> References: <54CDFC99.5000900@home.nl> <54CE091B.2070301@home.nl> <54CE61ED.20105@home.nl> Message-ID: On 2/02/2015, at 6:27 am, Roelof Wobben wrote: > This solution better ? > > concatenate([]) -> > []. > > concatenate([List] ) -> > concatenate2(List1, []). > > concatenate2([], List) -> > List; > > concatenate2([Head| Tail], List) -> > concatenate2(Tail, [Head | List]) No., To be honest, it is a b----y bad solution. WHERE ARE THE [UNPRINTABLE] COMMENTS? Because of this thread, I know what concatenate/2 is supposed to do, BUT YOU HAVE NOT TOLD US WHAT concatenat2/2 IS SUPPOSED TO DO. In fact concatenate2/2 appears to be reversal, which is something you definitely do NOT want. What you have here is > concatenate([]). [] > concatenate([[a,b,c]]). [c,b,a] > concatenate([[a,b,c], [1,2,3]]). NO MATCH The basic scheme for processing lists by recursion is g([H|T], Context) -> f(H, g(T, Context), Context); g([], Context) -> e(Context). where g is the function we are trying to define e is what to do for an empty list f is what to do for a non-empty list GIVEN the result of a recursive call on the tail. e() and f(_,_) do not have to be literal function calls; they could be any expression. So we are looking for concatenate([H|T]) -> f(H, concatenate(T)); concatenate([]) -> e(). You know what concatenate([]) is, so we're looking for concatenate([H|T]) -> f(H, concatenate(T)); concatenate([]) -> []. Now H : list(X) concatenate (list(list(X)) -> list(X)) so concatenate(T) : list(X) and you need to find an expression f(A, B) such that when A and B are lists, so is f(A, B), and the result has all the elements of A followed by all the elements of B. If you really do want a helper function (and there is a built-in operator that does *precisely* what you need), start by writing the comment: % concatenate_helper(A : list(X), B : list(X)) -> R : list(X) % R is a list containing all the elements of A followed by % all the elements of B and nothing else. By this point in the book, if you haven't heard of the built-in operator that does this, you have probably written your own function for it already. From ok@REDACTED Mon Feb 2 03:14:19 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 2 Feb 2015 15:14:19 +1300 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CE091B.2070301@home.nl> References: <54CDFC99.5000900@home.nl> <54CE091B.2070301@home.nl> Message-ID: <95A51DBB-C8B5-4D01-8B0D-908DE39C7A8A@cs.otago.ac.nz> On 2/02/2015, at 12:08 am, Roelof Wobben wrote: > > But there is one problem. > > The source is full of -spec and in programming erlang that is explained in chapter 18 where Im trying exercises of chapter 3. So what? IGNORE THOSE LINES for now. Run, do not walk, to your web browser. Enter this URL into the address box: http://www.cs.otago.ac.nz/cosc345/bickerton.htm It seems to me that you need Bickerton's advice about how to read even more urgently than you need a book about Erlang, because Bickerton is telling HOW TO READ a book like that. "Most students hit their heads on brick walls. They're given a text to read, and somewhere in Chapter 1 or 2 they bog down completely. But they persevere, oh, do they persevere!" That sounds a lot like you, to be honest. When I am reading biology or bioinformatics books and papers, if I stopped whenever I got stuck I'd be lost in paragraph 1 or paragraph 2 (never mind chapters!). Only by following Bickerton's advice do I get anywhere, and I *do* learn something. It may not be what the author cared about, but every time, I learn *something*. From r.wobben@REDACTED Mon Feb 2 08:02:45 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Mon, 02 Feb 2015 08:02:45 +0100 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: References: <54CDFC99.5000900@home.nl> <54CE091B.2070301@home.nl> <54CE61ED.20105@home.nl> Message-ID: <54CF2115.1040901@home.nl> Richard A. O'Keefe schreef op 2-2-2015 om 3:25: > On 2/02/2015, at 6:27 am, Roelof Wobben wrote: >> This solution better ? >> >> concatenate([]) -> >> []. >> >> concatenate([List] ) -> >> concatenate2(List1, []). >> >> concatenate2([], List) -> >> List; >> >> concatenate2([Head| Tail], List) -> >> concatenate2(Tail, [Head | List]) > No., To be honest, it is a b----y bad solution. > > WHERE ARE THE [UNPRINTABLE] COMMENTS? > Because of this thread, I know what concatenate/2 > is supposed to do, BUT YOU HAVE NOT TOLD US WHAT > concatenat2/2 IS SUPPOSED TO DO. > > In fact concatenate2/2 appears to be reversal, > which is something you definitely do NOT want. > > What you have here is > > > concatenate([]). > [] > > concatenate([[a,b,c]]). > [c,b,a] > > concatenate([[a,b,c], [1,2,3]]). > NO MATCH > > The basic scheme for processing lists by recursion is > > g([H|T], Context) -> > f(H, g(T, Context), Context); > g([], Context) -> > e(Context). > > where g is the function we are trying to define > e is what to do for an empty list > f is what to do for a non-empty list > GIVEN the result of a recursive call on the tail. > e() and f(_,_) do not have to be literal function > calls; they could be any expression. > > > So we are looking for > > concatenate([H|T]) -> > f(H, concatenate(T)); > concatenate([]) -> > e(). > > You know what concatenate([]) is, so we're looking for > > concatenate([H|T]) -> > f(H, concatenate(T)); > concatenate([]) -> > []. > > Now H : list(X) > concatenate (list(list(X)) -> list(X)) > so concatenate(T) : list(X) > and you need to find an expression f(A, B) > such that when A and B are lists, so is f(A, B), > and the result has all the elements of A followed > by all the elements of B. > > If you really do want a helper function (and there is > a built-in operator that does *precisely* what you > need), start by writing the comment: > > % concatenate_helper(A : list(X), B : list(X)) -> R : list(X) > % R is a list containing all the elements of A followed by > % all the elements of B and nothing else. > > By this point in the book, if you haven't heard of the built-in > operator that does this, you have probably written your own > function for it already. > > > Thanks, Now Im doubt or looking for a erlang book which takes lesser steps and explain things like recursion in smaller steps or that Erlang is not the language for me. Roelof From sdl.web@REDACTED Mon Feb 2 10:46:28 2015 From: sdl.web@REDACTED (Leo Liu) Date: Mon, 02 Feb 2015 17:46:28 +0800 Subject: [erlang-questions] ttb.erl and dbg.erl Message-ID: Hi list, I am curious why there are these awfully similar things? Thanks, Leo From vances@REDACTED Mon Feb 2 17:45:24 2015 From: vances@REDACTED (Vance Shipley) Date: Mon, 2 Feb 2015 22:15:24 +0530 Subject: [erlang-questions] MIT SprayList for Schedulers? Message-ID: Is the recently announced work at MIT on priority queues something which the BEAM emulator could benefit from? http://newsoffice.mit.edu/2015/new-priority-queues-data-structure-0130 http://www.mit.edu/~jerryzli/SprayList-CR.pdf -- -Vance From jesper.louis.andersen@REDACTED Mon Feb 2 18:45:42 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Mon, 2 Feb 2015 18:45:42 +0100 Subject: [erlang-questions] MIT SprayList for Schedulers? In-Reply-To: References: Message-ID: On Mon, Feb 2, 2015 at 5:45 PM, Vance Shipley wrote: > Is the recently announced work at MIT on priority queues something > which the BEAM emulator could benefit from? > Where do you propose to use what is essentially a lock-free Skip List implementation they seem to call a SprayList? Note that the problem the researchers are trying to solve is to get more parallelism out of a sequential problem. These are usually uncommon in Erlang systems which are serial and concurrent in nature, much the opposite of the problem the researchers are trying to solve. It may be they have a use somewhere, but I have a hunch it has to be around ETS or another place with high core contention inside the system. Maybe the timer wheels. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Tue Feb 3 02:01:17 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Tue, 3 Feb 2015 14:01:17 +1300 Subject: [erlang-questions] concentate solution well ?? In-Reply-To: <54CF2115.1040901@home.nl> References: <54CDFC99.5000900@home.nl> <54CE091B.2070301@home.nl> <54CE61ED.20105@home.nl> <54CF2115.1040901@home.nl> Message-ID: <97CBE493-FEF7-4C11-A6B1-838C39C8AFAA@cs.otago.ac.nz> On 2/02/2015, at 8:02 pm, Roelof Wobben wrote: > > Now Im doubt or looking for a erlang book which takes lesser steps and explain things like recursion in smaller steps or that Erlang is not the language for me. The thing that is hardest to explain about recursion is that there is nothing to explain. It isn't any harder to understand than iteration. Let's take the task of removing N bottles of beer from the wall. If N = 0, there is nothing left to do. If N > 0, there is a first bottle of beer to remove, and then there are N-1 bottles to remove and the trick for BOTH iteration and recursion is that you get to do "remove N-1 bottles" with the *same* "remove N bottles" code that you are writing. Using familiar notation for loops: N = 99; while (!(N == 0)) { /* while not stopping */ remove_first_bottle(); N--; /* Play it again, Sam! */ } Using recursion: long_song(99) where long_song(0) -> % stopping ok; long_song(N) -> remove_first_bottle(), long_song(N-1). % Play it again, Sam! In both cases, you have to sort out: - How do you know when to stop? - What are you going to do when you stop? - How do you know when to keep going? - What are you going to do in the body of the loop/recursive case? - What is it that gets smaller on each "iteration"? In this example, it's - Stop when N = 0 - Do nothing in that case - Continue when N > 0 (not explicitly tested) - Remove one bottle - N gets smaller; eventually it reaches 0 and we stop. Now the thing that is *really* tricky here is that while loops come with an absurd and arbitrary restriction. You can only do "the remaining iterations" *after* you have done the current iteration. But why not do it like this: If N = 0, there is nothing left to do. If N > 0, remove N - 1 bottles and then remove any remaining bottle. Or long_song(0) -> ok; long_song(N) -> long_song(N-1), remove_any_bottle(). Iteration is just a bizarrely restricted special case of recursion. In both cases the essential idea is to handle an arbitrary number of steps with ONE piece of code that somehow (by explcit call or implicit jump) re-enters itself, so that *one* form handles *any* number of things. In both cases, you have to make sure that some measure of the problem size (the length of a list, the number of things left to work on, the size of a tree, whatever) is strictly smaller every time you go around again. Really, except for a few minor syntax issues, none of the problems you have been having really have anything to do with Erlang. Possibly THE major problem you are having is not starting by clearly grasping the problem and writing down your understanding as comments. If what I am about to write seems nasty to you, I apologise, but here it is: it looks as though you are trying to solve programming problems by hacking away at them in the hopes that they will eventually succumb, instead of starting by trying to analyse them clearly. That approach is not going to get you far with any programming language. If you are having trouble with recursion, then make tracks NOW for a copy of The Little Schemer. From bryan@REDACTED Tue Feb 3 03:36:36 2015 From: bryan@REDACTED (Bryan) Date: Mon, 2 Feb 2015 18:36:36 -0800 Subject: [erlang-questions] Building erlang R1603-1 on CentOS - unable to load crypto library Message-ID: Howdy fellow Erlangers, I have built many many Erlang systems from source, but today I am having a very unusual problem in that no matter how I build erlang, it fails to link properly to the crypto libraries. Here is the issue: [adam-dev@REDACTED otp_src_R16B03-1]$ erl Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Eshell V5.10.4 (abort with ^G) 1> l(crypto). {error,on_load_failure} =ERROR REPORT==== 2-Feb-2015::18:26:50 === Unable to load crypto library. Failed with error: "load_failed, Failed to load NIF library: '/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: undefined symbol: EC_GROUP_new_curve_GF2m'" OpenSSL might not be installed on this system. =ERROR REPORT==== 2-Feb-2015::18:26:50 === The on_load function for module crypto returned {error, {load_failed, "Failed to load NIF library: '/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: undefined symbol: EC_GROUP_new_curve_GF2m'?}} The shared library is there: [adam-dev@REDACTED otp_src_R16B03-1]$ ls -la /home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so -rwxr-xr-x. 1 adam-dev adam-dev 172170 Feb 2 18:25 /home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so I did find this in the log: gcc -c -o ../priv/obj/x86_64-unknown-linux-gnu/crypto.o -Werror=return-type -Wall -Wstrict-prototypes -Wmissing-prototypes -Wdeclaration-after-statement -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS -D_POSIX_THREAD_SAFE_FUNCTIONS -m64 -g -O2 -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/x86_64-unknown-linux-gnu -fno-tree-copyrename -D_GNU_SOURCE -fPIC -DHAVE_DYNAMIC_CRYPTO_LIB -I/usr/include -I/usr/include -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/emulator/beam -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/x86_64-unknown-linux-gnu -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/internal -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/internal/x86_64-unknown-linux-gnu -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/emulator/sys/unix crypto.c crypto.c: In function ?ec_key_new?: crypto.c:3018: warning: implicit declaration of function ?EC_GROUP_new_curve_GF2m? crypto.c:3018: warning: assignment makes pointer from integer without a cast The rest of the details. I have a brand spanking new CentOS install: [adam-dev@REDACTED otp_src_R16B03-1]$ uname -a Linux localhost.localdomain 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux Here is the installation information for openssl and openssl-devel: [adam-dev@REDACTED otp_src_R16B03-1]$ yum info openssl Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.keystealth.org * extras: mirror.hostduplex.com * updates: mirror.pac-12.org Installed Packages Name : openssl Arch : x86_64 Version : 1.0.1e Release : 30.el6_6.5 Size : 4.0 M Repo : installed From repo : updates Summary : A general purpose cryptography library with TLS implementation URL : http://www.openssl.org/ License : OpenSSL Description : The OpenSSL toolkit provides support for secure communications between : machines. OpenSSL includes a certificate management tool and shared : libraries which provide various cryptographic algorithms and : protocols. Available Packages Name : openssl Arch : i686 Version : 1.0.1e Release : 30.el6_6.5 Size : 1.5 M Repo : updates Summary : A general purpose cryptography library with TLS implementation URL : http://www.openssl.org/ License : OpenSSL Description : The OpenSSL toolkit provides support for secure communications between : machines. OpenSSL includes a certificate management tool and shared : libraries which provide various cryptographic algorithms and : protocols. [adam-dev@REDACTED otp_src_R16B03-1]$ yum info openssl-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: mirror.keystealth.org * extras: mirror.hostduplex.com * updates: mirror.pac-12.org Installed Packages Name : openssl-devel Arch : x86_64 Version : 1.0.1e Release : 30.el6_6.5 Size : 2.2 M Repo : installed From repo : updates Summary : Files for development of applications which will use OpenSSL URL : http://www.openssl.org/ License : OpenSSL Description : OpenSSL is a toolkit for supporting cryptography. The openssl-devel : package contains include files needed to develop applications which : support various cryptographic algorithms and protocols. Available Packages Name : openssl-devel Arch : i686 Version : 1.0.1e Release : 30.el6_6.5 Size : 1.2 M Repo : updates Summary : Files for development of applications which will use OpenSSL URL : http://www.openssl.org/ License : OpenSSL Description : OpenSSL is a toolkit for supporting cryptography. The openssl-devel : package contains include files needed to develop applications which : support various cryptographic algorithms and protocols. And here is my configuration: [adam-dev@REDACTED otp_src_R16B03-1]$ ./configure --prefix=/home/adam-dev/erlang/R16B03-1 --enable-ssl=yes --enable-kernel-poll --enable-smp-support --enable-threads --with-odbc=yes --enable-m64-build Configure finds everything ok. Here is snippet of the output relating to ssl: checking for OpenSSL >= 0.9.7 in standard locations... /usr checking for OpenSSL kerberos 5 support... yes checking for krb5.h in standard locations... found in /usr/include checking for ssl runtime library path to use... /usr/lib64:/usr/local/lib64:/usr/sfw/lib64:/opt/local/lib64:/usr/pkg/lib64:/usr/local/openssl/lib64:/usr/lib/openssl/lib64:/usr/openssl/lib64:/usr/local/ssl/lib64:/usr/lib/ssl/lib64:/usr/ssl/lib64:/usr/local/lib:/usr/sfw/lib:/usr/lib:/opt/local/lib:/usr/pkg/lib:/usr/local/openssl/lib:/usr/lib/openssl/lib:/usr/openssl/lib:/usr/local/ssl/lib:/usr/lib/ssl/lib:/usr/ssl/lib make and make install complete without error. Another snippet: === Entering application crypto make[3]: Entering directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" release_spec make[4]: Entering directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' /usr/bin/install -c -d "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/src" /usr/bin/install -c -m 644 crypto_app.erl crypto.erl crypto_server.erl crypto_sup.erl "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/src" /usr/bin/install -c -d "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/ebin" /usr/bin/install -c -m 644 ../ebin/crypto_app.beam ../ebin/crypto.beam ../ebin/crypto_server.beam ../ebin/crypto_sup.beam ../ebin/crypto.app \ ../ebin/crypto.appup "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/ebin" make[4]: Leaving directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' make[3]: Leaving directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' make[3]: Entering directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' make -f x86_64-unknown-linux-gnu/Makefile release make[4]: Entering directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" release_spec make[5]: Entering directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' make -f x86_64-unknown-linux-gnu/Makefile release_spec make[6]: Entering directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' /usr/bin/install -c -d "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" /usr/bin/install -c -d "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" /usr/bin/install -c -m 644 ../priv/Makefile "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" /usr/bin/install -c ../priv/obj/x86_64-unknown-linux-gnu/crypto.o "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" /usr/bin/install -c ../priv/lib/x86_64-unknown-linux-gnu/crypto.so "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" /usr/bin/install -c ../priv/obj/x86_64-unknown-linux-gnu/crypto_callback.o "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" /usr/bin/install -c ../priv/lib/x86_64-unknown-linux-gnu/crypto_callback.so "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" make[6]: Leaving directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' make[5]: Leaving directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' make[4]: Leaving directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' make[3]: Leaving directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' make[3]: Entering directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" release_spec make[4]: Entering directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' make[4]: Nothing to be done for `release_spec'. make[4]: Leaving directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' make[3]: Leaving directory `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' === Leaving application crypto Any help would be greatly appreciated! Cheers, Bryan ---- Bryan Hughes Go Factory http://www.go-factory.net Connecting the Internet of Things -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan@REDACTED Tue Feb 3 04:00:51 2015 From: bryan@REDACTED (Bryan) Date: Mon, 2 Feb 2015 19:00:51 -0800 Subject: [erlang-questions] Building erlang R1603-1 on CentOS - unable to load crypto library In-Reply-To: References: Message-ID: <88E44961-52A0-4C30-A0BB-81150AF5AE98@go-factory.net> Thank you so much - you rock! You saved me a headache and I really appreciate it. Adding the group back in, for prosperity reasons if someone is searching the list. Cheers, Bryan ---- Bryan Hughes Go Factory http://www.go-factory.net Connecting the Internet of Things > On Feb 2, 2015, at 6:57 PM, Vance Shipley wrote: > > This problem is described here: > > http://erlang.org/pipermail/erlang-questions/2013-December/076327.html > > Configure with: > > CFLAGS="-DOPENSSL_NO_EC=1" ./configure > > > > On Tue, Feb 3, 2015 at 8:06 AM, Bryan wrote: >> Howdy fellow Erlangers, >> >> I have built many many Erlang systems from source, but today I am having a >> very unusual problem in that no matter how I build erlang, it fails to link >> properly to the crypto libraries. >> >> Here is the issue: >> >> [adam-dev@REDACTED otp_src_R16B03-1]$ erl >> Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:8:8] [async-threads:10] >> [hipe] [kernel-poll:false] >> >> Eshell V5.10.4 (abort with ^G) >> 1> l(crypto). >> {error,on_load_failure} >> >> =ERROR REPORT==== 2-Feb-2015::18:26:50 === >> Unable to load crypto library. Failed with error: >> "load_failed, Failed to load NIF library: >> '/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: >> undefined symbol: EC_GROUP_new_curve_GF2m'" >> OpenSSL might not be installed on this system. >> >> =ERROR REPORT==== 2-Feb-2015::18:26:50 === >> The on_load function for module crypto returned {error, >> {load_failed, >> "Failed to load NIF >> library: >> '/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: >> undefined symbol: EC_GROUP_new_curve_GF2m'?}} >> >> The shared library is there: >> >> [adam-dev@REDACTED otp_src_R16B03-1]$ ls -la >> /home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so >> -rwxr-xr-x. 1 adam-dev adam-dev 172170 Feb 2 18:25 >> /home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so >> >> I did find this in the log: >> >> gcc -c -o ../priv/obj/x86_64-unknown-linux-gnu/crypto.o -Werror=return-type >> -Wall -Wstrict-prototypes -Wmissing-prototypes -Wdeclaration-after-statement >> -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS >> -D_POSIX_THREAD_SAFE_FUNCTIONS -m64 -g -O2 >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/x86_64-unknown-linux-gnu >> -fno-tree-copyrename -D_GNU_SOURCE -fPIC -DHAVE_DYNAMIC_CRYPTO_LIB >> -I/usr/include -I/usr/include >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/emulator/beam >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/x86_64-unknown-linux-gnu >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/internal >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/internal/x86_64-unknown-linux-gnu >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/emulator/sys/unix crypto.c >> crypto.c: In function ?ec_key_new?: >> crypto.c:3018: warning: implicit declaration of function >> ?EC_GROUP_new_curve_GF2m? >> crypto.c:3018: warning: assignment makes pointer from integer without a cast >> >> >> >> The rest of the details. I have a brand spanking new CentOS install: >> >> [adam-dev@REDACTED otp_src_R16B03-1]$ uname -a >> Linux localhost.localdomain 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 >> 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux >> >> Here is the installation information for openssl and openssl-devel: >> >> [adam-dev@REDACTED otp_src_R16B03-1]$ yum info openssl >> Loaded plugins: fastestmirror >> Loading mirror speeds from cached hostfile >> * base: mirror.keystealth.org >> * extras: mirror.hostduplex.com >> * updates: mirror.pac-12.org >> Installed Packages >> Name : openssl >> Arch : x86_64 >> Version : 1.0.1e >> Release : 30.el6_6.5 >> Size : 4.0 M >> Repo : installed >> From repo : updates >> Summary : A general purpose cryptography library with TLS implementation >> URL : http://www.openssl.org/ >> License : OpenSSL >> Description : The OpenSSL toolkit provides support for secure communications >> between >> : machines. OpenSSL includes a certificate management tool and >> shared >> : libraries which provide various cryptographic algorithms and >> : protocols. >> >> Available Packages >> Name : openssl >> Arch : i686 >> Version : 1.0.1e >> Release : 30.el6_6.5 >> Size : 1.5 M >> Repo : updates >> Summary : A general purpose cryptography library with TLS implementation >> URL : http://www.openssl.org/ >> License : OpenSSL >> Description : The OpenSSL toolkit provides support for secure communications >> between >> : machines. OpenSSL includes a certificate management tool and >> shared >> : libraries which provide various cryptographic algorithms and >> : protocols. >> >> [adam-dev@REDACTED otp_src_R16B03-1]$ yum info openssl-devel >> Loaded plugins: fastestmirror >> Loading mirror speeds from cached hostfile >> * base: mirror.keystealth.org >> * extras: mirror.hostduplex.com >> * updates: mirror.pac-12.org >> Installed Packages >> Name : openssl-devel >> Arch : x86_64 >> Version : 1.0.1e >> Release : 30.el6_6.5 >> Size : 2.2 M >> Repo : installed >> From repo : updates >> Summary : Files for development of applications which will use OpenSSL >> URL : http://www.openssl.org/ >> License : OpenSSL >> Description : OpenSSL is a toolkit for supporting cryptography. The >> openssl-devel >> : package contains include files needed to develop applications >> which >> : support various cryptographic algorithms and protocols. >> >> Available Packages >> Name : openssl-devel >> Arch : i686 >> Version : 1.0.1e >> Release : 30.el6_6.5 >> Size : 1.2 M >> Repo : updates >> Summary : Files for development of applications which will use OpenSSL >> URL : http://www.openssl.org/ >> License : OpenSSL >> Description : OpenSSL is a toolkit for supporting cryptography. The >> openssl-devel >> : package contains include files needed to develop applications >> which >> : support various cryptographic algorithms and protocols. >> >> And here is my configuration: >> >> [adam-dev@REDACTED otp_src_R16B03-1]$ ./configure >> --prefix=/home/adam-dev/erlang/R16B03-1 --enable-ssl=yes >> --enable-kernel-poll --enable-smp-support --enable-threads --with-odbc=yes >> --enable-m64-build >> >> Configure finds everything ok. Here is snippet of the output relating to >> ssl: >> >> checking for OpenSSL >= 0.9.7 in standard locations... /usr >> checking for OpenSSL kerberos 5 support... yes >> checking for krb5.h in standard locations... found in /usr/include >> checking for ssl runtime library path to use... >> /usr/lib64:/usr/local/lib64:/usr/sfw/lib64:/opt/local/lib64:/usr/pkg/lib64:/usr/local/openssl/lib64:/usr/lib/openssl/lib64:/usr/openssl/lib64:/usr/local/ssl/lib64:/usr/lib/ssl/lib64:/usr/ssl/lib64:/usr/local/lib:/usr/sfw/lib:/usr/lib:/opt/local/lib:/usr/pkg/lib:/usr/local/openssl/lib:/usr/lib/openssl/lib:/usr/openssl/lib:/usr/local/ssl/lib:/usr/lib/ssl/lib:/usr/ssl/lib >> >> make and make install complete without error. Another snippet: >> >> === Entering application crypto >> make[3]: Entering directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' >> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" >> release_spec >> make[4]: Entering directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' >> /usr/bin/install -c -d >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/src" >> /usr/bin/install -c -m 644 crypto_app.erl crypto.erl crypto_server.erl >> crypto_sup.erl >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/src" >> /usr/bin/install -c -d >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/ebin" >> /usr/bin/install -c -m 644 ../ebin/crypto_app.beam ../ebin/crypto.beam >> ../ebin/crypto_server.beam ../ebin/crypto_sup.beam ../ebin/crypto.app \ >> ../ebin/crypto.appup >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/ebin" >> make[4]: Leaving directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' >> make[3]: Leaving directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' >> make[3]: Entering directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >> make -f x86_64-unknown-linux-gnu/Makefile release >> make[4]: Entering directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" >> release_spec >> make[5]: Entering directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >> make -f x86_64-unknown-linux-gnu/Makefile release_spec >> make[6]: Entering directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >> /usr/bin/install -c -d >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" >> /usr/bin/install -c -d >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" >> /usr/bin/install -c -m 644 ../priv/Makefile >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" >> /usr/bin/install -c ../priv/obj/x86_64-unknown-linux-gnu/crypto.o >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" >> /usr/bin/install -c ../priv/lib/x86_64-unknown-linux-gnu/crypto.so >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" >> /usr/bin/install -c ../priv/obj/x86_64-unknown-linux-gnu/crypto_callback.o >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" >> /usr/bin/install -c ../priv/lib/x86_64-unknown-linux-gnu/crypto_callback.so >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" >> make[6]: Leaving directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >> make[5]: Leaving directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >> make[4]: Leaving directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >> make[3]: Leaving directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >> make[3]: Entering directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' >> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" >> release_spec >> make[4]: Entering directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' >> make[4]: Nothing to be done for `release_spec'. >> make[4]: Leaving directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' >> make[3]: Leaving directory >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' >> === Leaving application crypto >> >> >> Any help would be greatly appreciated! >> >> Cheers, >> Bryan >> >> ---- >> >> Bryan Hughes >> Go Factory >> >> http://www.go-factory.net >> >> Connecting the Internet of Things >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > -- > -Vance From ted@REDACTED Tue Feb 3 04:53:34 2015 From: ted@REDACTED (Ted Kaehler) Date: Mon, 2 Feb 2015 19:53:34 -0800 Subject: [erlang-questions] Typos in 'getting_started-5.4' Message-ID: Folks, Thank you for your detailed and easy-to-read document, 'getting_started-5.4'. Here are some corrections. Just search for the quotation to find it in the document. Erlang does not have a string *date* type *date* should be data The .erlang.cookie file should contain *on* line with the same atom. *on* should be one This example will just show the message passing logic no attempt at all has been made something left out after *logic*? Start a new sentence? Logs off anybody at *at* node *at* should be that Note the use of the spawn_link BIF. (spawn_link is not actually called in that example.) processes *mesage* queue. *mesage* should be message I really appreciate the fact that this document is freely available on the web! Thanks for all the hard work. --Ted. -------------- next part -------------- An HTML attachment was scrubbed... URL: From uaforum1@REDACTED Tue Feb 3 07:09:08 2015 From: uaforum1@REDACTED (u a) Date: Tue, 3 Feb 2015 07:09:08 +0100 Subject: [erlang-questions] Erlang course material Message-ID: Hi, my name is Ulf Angermann and i live in germany. Perhaps, you now, that Erlang projects in germany are very rare, but i don't give up to get one. After a talk and a PoC by a customer, he decided to add Erlang at their toolbox. They asked me, if am able to give a course to their developers and architects.I told them that i can do it, but i have to create the training material, first and this can take a while. My question is, is there any open source training material available or is there a company from which i can buy the material? BR's Ulf Angermann -------------- next part -------------- An HTML attachment was scrubbed... URL: From drormein@REDACTED Tue Feb 3 08:04:05 2015 From: drormein@REDACTED (Dror Mein) Date: Tue, 3 Feb 2015 07:04:05 +0000 (UTC) Subject: [erlang-questions] tidier In-Reply-To: References: Message-ID: <1182213658.1371714.1422947045362.JavaMail.yahoo@mail.yahoo.com> I went over the presentation a while ago, and forgot about it. Three weeks ago I came across it once again in the abstract of an erlang factory presentation, and thought, let's see what I remember... Ever since, I've been using examples on how to clean up my code daily. It's open in a browser tab all the time, and I've linked it to others, to explain stuff. This love letter is not just a recommendation to all who speak erlang to use it whenever possible. It is also a plea: could someone please find me the source code to the application? the link is broken. Besides the thrill of seeing an erl_crash live online and not just in my computer, I'm heartbroken. Anyone? On Tuesday, January 20, 2015 1:26 PM, Tuncer Ayaz wrote: On Tue, Jan 20, 2015 at 10:32 AM, Dror Mein wrote: > does anyone know where to find the tidier application? there is a > link to a webpage that i get and erl_error from. http://tidier.softlab.ntua.gr/ Looks like it fails to find erlyweb:out and therefore doesn't load. Kostis? -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists@REDACTED Tue Feb 3 09:41:48 2015 From: lists@REDACTED (Camille Troillard) Date: Tue, 3 Feb 2015 09:41:48 +0100 Subject: [erlang-questions] Using processes to implement business logic In-Reply-To: References: Message-ID: <68A3AB0E-6E56-42E5-9D14-E6F74DD085B3@tuli.pe> Thank you Jesper for this nice explanation. On 31 Jan 2015, at 16:23, Jesper Louis Andersen wrote: > On Fri, Jan 30, 2015 at 11:52 AM, Camille Troillard wrote: > It looks like, in the context of our problem, we should have more advantages implementing our domain model using processes rather than simple Erlang records. It also appears that processes will act as a nice cache layer in front of the persistent storage. > > In the words of the Subject/Object dichotomy[0]: do you want your business entities to "act" or be "acted upon" ? > > If the former is true, then make them into processes. This is often the case if your entities are "alive" and needs to query databases, have timeouts, needs to manage persistence and so on. Or if the processing of an entity is complex with many different advanced code paths. > > If the latter is true, then make them into records. This is usually good if your data can be batch-processed and is just "dead" data, where other systems are using that data to work. This often leads to a pipeline processing chain where workers (subjects) operate on the entities. This is also the only viable model in many programming languages. > > [0] http://en.wikipedia.org/wiki/Subject%E2%80%93object_problem > > -- > J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dm.klionsky@REDACTED Tue Feb 3 13:03:12 2015 From: dm.klionsky@REDACTED (Dmitry Klionsky) Date: Tue, 03 Feb 2015 15:03:12 +0300 Subject: [erlang-questions] Building erlang R1603-1 on CentOS - unable to load crypto library In-Reply-To: <88E44961-52A0-4C30-A0BB-81150AF5AE98@go-factory.net> References: <88E44961-52A0-4C30-A0BB-81150AF5AE98@go-factory.net> Message-ID: <54D0B900.50201@gmail.com> Hi, It' not the whole story. The flags should be CFLAGS="-DOPENSSL_NO_EC=1 -g -O2" ./configure More details here http://erlang.org/pipermail/erlang-questions/2014-July/080317.html http://erlang.org/pipermail/erlang-questions/2014-August/080353.html BR On 02/03/2015 06:00 AM, Bryan wrote: > Thank you so much - you rock! You saved me a headache and I really appreciate it. > > Adding the group back in, for prosperity reasons if someone is searching the list. > > Cheers, > Bryan > > ---- > > Bryan Hughes > Go Factory > > http://www.go-factory.net > > Connecting the Internet of Things > >> On Feb 2, 2015, at 6:57 PM, Vance Shipley wrote: >> >> This problem is described here: >> >> http://erlang.org/pipermail/erlang-questions/2013-December/076327.html >> >> Configure with: >> >> CFLAGS="-DOPENSSL_NO_EC=1" ./configure >> >> >> >> On Tue, Feb 3, 2015 at 8:06 AM, Bryan wrote: >>> Howdy fellow Erlangers, >>> >>> I have built many many Erlang systems from source, but today I am having a >>> very unusual problem in that no matter how I build erlang, it fails to link >>> properly to the crypto libraries. >>> >>> Here is the issue: >>> >>> [adam-dev@REDACTED otp_src_R16B03-1]$ erl >>> Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:8:8] [async-threads:10] >>> [hipe] [kernel-poll:false] >>> >>> Eshell V5.10.4 (abort with ^G) >>> 1> l(crypto). >>> {error,on_load_failure} >>> >>> =ERROR REPORT==== 2-Feb-2015::18:26:50 === >>> Unable to load crypto library. Failed with error: >>> "load_failed, Failed to load NIF library: >>> '/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: >>> undefined symbol: EC_GROUP_new_curve_GF2m'" >>> OpenSSL might not be installed on this system. >>> >>> =ERROR REPORT==== 2-Feb-2015::18:26:50 === >>> The on_load function for module crypto returned {error, >>> {load_failed, >>> "Failed to load NIF >>> library: >>> '/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: >>> undefined symbol: EC_GROUP_new_curve_GF2m'?}} >>> >>> The shared library is there: >>> >>> [adam-dev@REDACTED otp_src_R16B03-1]$ ls -la >>> /home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so >>> -rwxr-xr-x. 1 adam-dev adam-dev 172170 Feb 2 18:25 >>> /home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so >>> >>> I did find this in the log: >>> >>> gcc -c -o ../priv/obj/x86_64-unknown-linux-gnu/crypto.o -Werror=return-type >>> -Wall -Wstrict-prototypes -Wmissing-prototypes -Wdeclaration-after-statement >>> -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS >>> -D_POSIX_THREAD_SAFE_FUNCTIONS -m64 -g -O2 >>> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/x86_64-unknown-linux-gnu >>> -fno-tree-copyrename -D_GNU_SOURCE -fPIC -DHAVE_DYNAMIC_CRYPTO_LIB >>> -I/usr/include -I/usr/include >>> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/emulator/beam >>> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include >>> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/x86_64-unknown-linux-gnu >>> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/internal >>> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/internal/x86_64-unknown-linux-gnu >>> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/emulator/sys/unix crypto.c >>> crypto.c: In function ?ec_key_new?: >>> crypto.c:3018: warning: implicit declaration of function >>> ?EC_GROUP_new_curve_GF2m? >>> crypto.c:3018: warning: assignment makes pointer from integer without a cast >>> >>> >>> >>> The rest of the details. I have a brand spanking new CentOS install: >>> >>> [adam-dev@REDACTED otp_src_R16B03-1]$ uname -a >>> Linux localhost.localdomain 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 >>> 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux >>> >>> Here is the installation information for openssl and openssl-devel: >>> >>> [adam-dev@REDACTED otp_src_R16B03-1]$ yum info openssl >>> Loaded plugins: fastestmirror >>> Loading mirror speeds from cached hostfile >>> * base: mirror.keystealth.org >>> * extras: mirror.hostduplex.com >>> * updates: mirror.pac-12.org >>> Installed Packages >>> Name : openssl >>> Arch : x86_64 >>> Version : 1.0.1e >>> Release : 30.el6_6.5 >>> Size : 4.0 M >>> Repo : installed >>> From repo : updates >>> Summary : A general purpose cryptography library with TLS implementation >>> URL : http://www.openssl.org/ >>> License : OpenSSL >>> Description : The OpenSSL toolkit provides support for secure communications >>> between >>> : machines. OpenSSL includes a certificate management tool and >>> shared >>> : libraries which provide various cryptographic algorithms and >>> : protocols. >>> >>> Available Packages >>> Name : openssl >>> Arch : i686 >>> Version : 1.0.1e >>> Release : 30.el6_6.5 >>> Size : 1.5 M >>> Repo : updates >>> Summary : A general purpose cryptography library with TLS implementation >>> URL : http://www.openssl.org/ >>> License : OpenSSL >>> Description : The OpenSSL toolkit provides support for secure communications >>> between >>> : machines. OpenSSL includes a certificate management tool and >>> shared >>> : libraries which provide various cryptographic algorithms and >>> : protocols. >>> >>> [adam-dev@REDACTED otp_src_R16B03-1]$ yum info openssl-devel >>> Loaded plugins: fastestmirror >>> Loading mirror speeds from cached hostfile >>> * base: mirror.keystealth.org >>> * extras: mirror.hostduplex.com >>> * updates: mirror.pac-12.org >>> Installed Packages >>> Name : openssl-devel >>> Arch : x86_64 >>> Version : 1.0.1e >>> Release : 30.el6_6.5 >>> Size : 2.2 M >>> Repo : installed >>> From repo : updates >>> Summary : Files for development of applications which will use OpenSSL >>> URL : http://www.openssl.org/ >>> License : OpenSSL >>> Description : OpenSSL is a toolkit for supporting cryptography. The >>> openssl-devel >>> : package contains include files needed to develop applications >>> which >>> : support various cryptographic algorithms and protocols. >>> >>> Available Packages >>> Name : openssl-devel >>> Arch : i686 >>> Version : 1.0.1e >>> Release : 30.el6_6.5 >>> Size : 1.2 M >>> Repo : updates >>> Summary : Files for development of applications which will use OpenSSL >>> URL : http://www.openssl.org/ >>> License : OpenSSL >>> Description : OpenSSL is a toolkit for supporting cryptography. The >>> openssl-devel >>> : package contains include files needed to develop applications >>> which >>> : support various cryptographic algorithms and protocols. >>> >>> And here is my configuration: >>> >>> [adam-dev@REDACTED otp_src_R16B03-1]$ ./configure >>> --prefix=/home/adam-dev/erlang/R16B03-1 --enable-ssl=yes >>> --enable-kernel-poll --enable-smp-support --enable-threads --with-odbc=yes >>> --enable-m64-build >>> >>> Configure finds everything ok. Here is snippet of the output relating to >>> ssl: >>> >>> checking for OpenSSL >= 0.9.7 in standard locations... /usr >>> checking for OpenSSL kerberos 5 support... yes >>> checking for krb5.h in standard locations... found in /usr/include >>> checking for ssl runtime library path to use... >>> /usr/lib64:/usr/local/lib64:/usr/sfw/lib64:/opt/local/lib64:/usr/pkg/lib64:/usr/local/openssl/lib64:/usr/lib/openssl/lib64:/usr/openssl/lib64:/usr/local/ssl/lib64:/usr/lib/ssl/lib64:/usr/ssl/lib64:/usr/local/lib:/usr/sfw/lib:/usr/lib:/opt/local/lib:/usr/pkg/lib:/usr/local/openssl/lib:/usr/lib/openssl/lib:/usr/openssl/lib:/usr/local/ssl/lib:/usr/lib/ssl/lib:/usr/ssl/lib >>> >>> make and make install complete without error. Another snippet: >>> >>> === Entering application crypto >>> make[3]: Entering directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' >>> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" >>> release_spec >>> make[4]: Entering directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' >>> /usr/bin/install -c -d >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/src" >>> /usr/bin/install -c -m 644 crypto_app.erl crypto.erl crypto_server.erl >>> crypto_sup.erl >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/src" >>> /usr/bin/install -c -d >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/ebin" >>> /usr/bin/install -c -m 644 ../ebin/crypto_app.beam ../ebin/crypto.beam >>> ../ebin/crypto_server.beam ../ebin/crypto_sup.beam ../ebin/crypto.app \ >>> ../ebin/crypto.appup >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/ebin" >>> make[4]: Leaving directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' >>> make[3]: Leaving directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' >>> make[3]: Entering directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >>> make -f x86_64-unknown-linux-gnu/Makefile release >>> make[4]: Entering directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >>> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" >>> release_spec >>> make[5]: Entering directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >>> make -f x86_64-unknown-linux-gnu/Makefile release_spec >>> make[6]: Entering directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >>> /usr/bin/install -c -d >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" >>> /usr/bin/install -c -d >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" >>> /usr/bin/install -c -m 644 ../priv/Makefile >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" >>> /usr/bin/install -c ../priv/obj/x86_64-unknown-linux-gnu/crypto.o >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" >>> /usr/bin/install -c ../priv/lib/x86_64-unknown-linux-gnu/crypto.so >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" >>> /usr/bin/install -c ../priv/obj/x86_64-unknown-linux-gnu/crypto_callback.o >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" >>> /usr/bin/install -c ../priv/lib/x86_64-unknown-linux-gnu/crypto_callback.so >>> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" >>> make[6]: Leaving directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >>> make[5]: Leaving directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >>> make[4]: Leaving directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >>> make[3]: Leaving directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' >>> make[3]: Entering directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' >>> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" >>> release_spec >>> make[4]: Entering directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' >>> make[4]: Nothing to be done for `release_spec'. >>> make[4]: Leaving directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' >>> make[3]: Leaving directory >>> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' >>> === Leaving application crypto >>> >>> >>> Any help would be greatly appreciated! >>> >>> Cheers, >>> Bryan >>> >>> ---- >>> >>> Bryan Hughes >>> Go Factory >>> >>> http://www.go-factory.net >>> >>> Connecting the Internet of Things >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >> >> >> -- >> -- >> -Vance > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From e@REDACTED Tue Feb 3 14:07:13 2015 From: e@REDACTED (e@REDACTED) Date: Tue, 03 Feb 2015 14:07:13 +0100 Subject: [erlang-questions] Erlang course material In-Reply-To: References: Message-ID: <54D0C801.60700@bestmx.net> > My question is, is there any open source training material available or is > there a company from which i can buy the material? i would try to communicate with the guy behind learnyousomeerlang.com From luis.rascao@REDACTED Tue Feb 3 10:34:24 2015 From: luis.rascao@REDACTED (=?UTF-8?B?THVpcyBSYXNjw6Nv?=) Date: Tue, 3 Feb 2015 09:34:24 +0000 Subject: [erlang-questions] Building erlang R1603-1 on CentOS - unable to load crypto library In-Reply-To: <88E44961-52A0-4C30-A0BB-81150AF5AE98@go-factory.net> References: <88E44961-52A0-4C30-A0BB-81150AF5AE98@go-factory.net> Message-ID: Another option is to build OpenSSL and then statically link it with Erlang of your choosing (--with-ssl=/usr/local/openssl/ --disable-dynamic-ssl-lib) I would really like to know why would someone add a OpenSSL package with elliptic curves disabled... On Tue, Feb 3, 2015 at 3:00 AM, Bryan wrote: > Thank you so much - you rock! You saved me a headache and I really > appreciate it. > > Adding the group back in, for prosperity reasons if someone is searching > the list. > > Cheers, > Bryan > > ---- > > Bryan Hughes > Go Factory > > http://www.go-factory.net > > Connecting the Internet of Things > > > On Feb 2, 2015, at 6:57 PM, Vance Shipley wrote: > > > > This problem is described here: > > > > > http://erlang.org/pipermail/erlang-questions/2013-December/076327.html > > > > Configure with: > > > > CFLAGS="-DOPENSSL_NO_EC=1" ./configure > > > > > > > > On Tue, Feb 3, 2015 at 8:06 AM, Bryan wrote: > >> Howdy fellow Erlangers, > >> > >> I have built many many Erlang systems from source, but today I am > having a > >> very unusual problem in that no matter how I build erlang, it fails to > link > >> properly to the crypto libraries. > >> > >> Here is the issue: > >> > >> [adam-dev@REDACTED otp_src_R16B03-1]$ erl > >> Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [smp:8:8] > [async-threads:10] > >> [hipe] [kernel-poll:false] > >> > >> Eshell V5.10.4 (abort with ^G) > >> 1> l(crypto). > >> {error,on_load_failure} > >> > >> =ERROR REPORT==== 2-Feb-2015::18:26:50 === > >> Unable to load crypto library. Failed with error: > >> "load_failed, Failed to load NIF library: > >> > '/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: > >> undefined symbol: EC_GROUP_new_curve_GF2m'" > >> OpenSSL might not be installed on this system. > >> > >> =ERROR REPORT==== 2-Feb-2015::18:26:50 === > >> The on_load function for module crypto returned {error, > >> {load_failed, > >> "Failed to load NIF > >> library: > >> > '/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so: > >> undefined symbol: EC_GROUP_new_curve_GF2m'?}} > >> > >> The shared library is there: > >> > >> [adam-dev@REDACTED otp_src_R16B03-1]$ ls -la > >> > /home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so > >> -rwxr-xr-x. 1 adam-dev adam-dev 172170 Feb 2 18:25 > >> > /home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib/crypto.so > >> > >> I did find this in the log: > >> > >> gcc -c -o ../priv/obj/x86_64-unknown-linux-gnu/crypto.o > -Werror=return-type > >> -Wall -Wstrict-prototypes -Wmissing-prototypes > -Wdeclaration-after-statement > >> -DUSE_THREADS -D_THREAD_SAFE -D_REENTRANT -DPOSIX_THREADS > >> -D_POSIX_THREAD_SAFE_FUNCTIONS -m64 -g -O2 > >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/x86_64-unknown-linux-gnu > >> -fno-tree-copyrename -D_GNU_SOURCE -fPIC -DHAVE_DYNAMIC_CRYPTO_LIB > >> -I/usr/include -I/usr/include > >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/emulator/beam > >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include > >> > -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/x86_64-unknown-linux-gnu > >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/internal > >> > -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/include/internal/x86_64-unknown-linux-gnu > >> -I/home/adam-dev/erlang/otp_src_R16B03-1/erts/emulator/sys/unix crypto.c > >> crypto.c: In function ?ec_key_new?: > >> crypto.c:3018: warning: implicit declaration of function > >> ?EC_GROUP_new_curve_GF2m? > >> crypto.c:3018: warning: assignment makes pointer from integer without a > cast > >> > >> > >> > >> The rest of the details. I have a brand spanking new CentOS install: > >> > >> [adam-dev@REDACTED otp_src_R16B03-1]$ uname -a > >> Linux localhost.localdomain 2.6.32-279.14.1.el6.x86_64 #1 SMP Tue Nov 6 > >> 23:43:09 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux > >> > >> Here is the installation information for openssl and openssl-devel: > >> > >> [adam-dev@REDACTED otp_src_R16B03-1]$ yum info openssl > >> Loaded plugins: fastestmirror > >> Loading mirror speeds from cached hostfile > >> * base: mirror.keystealth.org > >> * extras: mirror.hostduplex.com > >> * updates: mirror.pac-12.org > >> Installed Packages > >> Name : openssl > >> Arch : x86_64 > >> Version : 1.0.1e > >> Release : 30.el6_6.5 > >> Size : 4.0 M > >> Repo : installed > >> From repo : updates > >> Summary : A general purpose cryptography library with TLS > implementation > >> URL : http://www.openssl.org/ > >> License : OpenSSL > >> Description : The OpenSSL toolkit provides support for secure > communications > >> between > >> : machines. OpenSSL includes a certificate management tool > and > >> shared > >> : libraries which provide various cryptographic algorithms > and > >> : protocols. > >> > >> Available Packages > >> Name : openssl > >> Arch : i686 > >> Version : 1.0.1e > >> Release : 30.el6_6.5 > >> Size : 1.5 M > >> Repo : updates > >> Summary : A general purpose cryptography library with TLS > implementation > >> URL : http://www.openssl.org/ > >> License : OpenSSL > >> Description : The OpenSSL toolkit provides support for secure > communications > >> between > >> : machines. OpenSSL includes a certificate management tool > and > >> shared > >> : libraries which provide various cryptographic algorithms > and > >> : protocols. > >> > >> [adam-dev@REDACTED otp_src_R16B03-1]$ yum info openssl-devel > >> Loaded plugins: fastestmirror > >> Loading mirror speeds from cached hostfile > >> * base: mirror.keystealth.org > >> * extras: mirror.hostduplex.com > >> * updates: mirror.pac-12.org > >> Installed Packages > >> Name : openssl-devel > >> Arch : x86_64 > >> Version : 1.0.1e > >> Release : 30.el6_6.5 > >> Size : 2.2 M > >> Repo : installed > >> From repo : updates > >> Summary : Files for development of applications which will use > OpenSSL > >> URL : http://www.openssl.org/ > >> License : OpenSSL > >> Description : OpenSSL is a toolkit for supporting cryptography. The > >> openssl-devel > >> : package contains include files needed to develop > applications > >> which > >> : support various cryptographic algorithms and protocols. > >> > >> Available Packages > >> Name : openssl-devel > >> Arch : i686 > >> Version : 1.0.1e > >> Release : 30.el6_6.5 > >> Size : 1.2 M > >> Repo : updates > >> Summary : Files for development of applications which will use > OpenSSL > >> URL : http://www.openssl.org/ > >> License : OpenSSL > >> Description : OpenSSL is a toolkit for supporting cryptography. The > >> openssl-devel > >> : package contains include files needed to develop > applications > >> which > >> : support various cryptographic algorithms and protocols. > >> > >> And here is my configuration: > >> > >> [adam-dev@REDACTED otp_src_R16B03-1]$ ./configure > >> --prefix=/home/adam-dev/erlang/R16B03-1 --enable-ssl=yes > >> --enable-kernel-poll --enable-smp-support --enable-threads > --with-odbc=yes > >> --enable-m64-build > >> > >> Configure finds everything ok. Here is snippet of the output relating to > >> ssl: > >> > >> checking for OpenSSL >= 0.9.7 in standard locations... /usr > >> checking for OpenSSL kerberos 5 support... yes > >> checking for krb5.h in standard locations... found in /usr/include > >> checking for ssl runtime library path to use... > >> > /usr/lib64:/usr/local/lib64:/usr/sfw/lib64:/opt/local/lib64:/usr/pkg/lib64:/usr/local/openssl/lib64:/usr/lib/openssl/lib64:/usr/openssl/lib64:/usr/local/ssl/lib64:/usr/lib/ssl/lib64:/usr/ssl/lib64:/usr/local/lib:/usr/sfw/lib:/usr/lib:/opt/local/lib:/usr/pkg/lib:/usr/local/openssl/lib:/usr/lib/openssl/lib:/usr/openssl/lib:/usr/local/ssl/lib:/usr/lib/ssl/lib:/usr/ssl/lib > >> > >> make and make install complete without error. Another snippet: > >> > >> === Entering application crypto > >> make[3]: Entering directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' > >> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" > >> release_spec > >> make[4]: Entering directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' > >> /usr/bin/install -c -d > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/src" > >> /usr/bin/install -c -m 644 crypto_app.erl crypto.erl crypto_server.erl > >> crypto_sup.erl > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/src" > >> /usr/bin/install -c -d > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/ebin" > >> /usr/bin/install -c -m 644 ../ebin/crypto_app.beam ../ebin/crypto.beam > >> ../ebin/crypto_server.beam ../ebin/crypto_sup.beam ../ebin/crypto.app \ > >> ../ebin/crypto.appup > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/ebin" > >> make[4]: Leaving directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' > >> make[3]: Leaving directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/src' > >> make[3]: Entering directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' > >> make -f x86_64-unknown-linux-gnu/Makefile release > >> make[4]: Entering directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' > >> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" > >> release_spec > >> make[5]: Entering directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' > >> make -f x86_64-unknown-linux-gnu/Makefile release_spec > >> make[6]: Entering directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' > >> /usr/bin/install -c -d > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" > >> /usr/bin/install -c -d > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" > >> /usr/bin/install -c -m 644 ../priv/Makefile > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" > >> /usr/bin/install -c ../priv/obj/x86_64-unknown-linux-gnu/crypto.o > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" > >> /usr/bin/install -c ../priv/lib/x86_64-unknown-linux-gnu/crypto.so > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" > >> /usr/bin/install -c > ../priv/obj/x86_64-unknown-linux-gnu/crypto_callback.o > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/obj" > >> /usr/bin/install -c > ../priv/lib/x86_64-unknown-linux-gnu/crypto_callback.so > >> "/home/adam-dev/erlang/R16B03-1/lib/erlang/lib/crypto-3.2/priv/lib" > >> make[6]: Leaving directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' > >> make[5]: Leaving directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' > >> make[4]: Leaving directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' > >> make[3]: Leaving directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/c_src' > >> make[3]: Entering directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' > >> make -w RELEASE_PATH="/home/adam-dev/erlang/R16B03-1/lib/erlang" > >> release_spec > >> make[4]: Entering directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' > >> make[4]: Nothing to be done for `release_spec'. > >> make[4]: Leaving directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' > >> make[3]: Leaving directory > >> `/home/adam-dev/erlang/otp_src_R16B03-1/lib/crypto/doc/src' > >> === Leaving application crypto > >> > >> > >> Any help would be greatly appreciated! > >> > >> Cheers, > >> Bryan > >> > >> ---- > >> > >> Bryan Hughes > >> Go Factory > >> > >> http://www.go-factory.net > >> > >> Connecting the Internet of Things > >> > >> > >> _______________________________________________ > >> erlang-questions mailing list > >> erlang-questions@REDACTED > >> http://erlang.org/mailman/listinfo/erlang-questions > >> > > > > > > > > -- > > -- > > -Vance > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From 459673409@REDACTED Tue Feb 3 12:28:50 2015 From: 459673409@REDACTED (=?utf-8?B?5pat6IiN56a7?=) Date: Tue, 3 Feb 2015 19:28:50 +0800 Subject: [erlang-questions] where start the poolboy privately?erlang database connection pools Message-ID: Thank you for reading my question!The URL is: http://stackoverflow.com/questions/28297708/where-start-the-poolboy-privatelyerlang-database-connection-pools? -------------- next part -------------- An HTML attachment was scrubbed... URL: From zandra@REDACTED Tue Feb 3 13:10:49 2015 From: zandra@REDACTED (Zandra Hird) Date: Tue, 3 Feb 2015 13:10:49 +0100 Subject: [erlang-questions] Patch package OTP 17.4.1 released Message-ID: <54D0BAC9.5070305@erlang.org> Patch Package: OTP 17.4.1 Git Tag: OTP-17.4.1 --------------------------------------------------------------------- --- erts-6.3.1 ------------------------------------------------------ --------------------------------------------------------------------- The erts-6.3.1 application can be applied independently of other applications on a full OTP 17 installation. --- Fixed Bugs and Malfunctions --- OTP-12445 Application(s): erts Fix getifaddrs realloc pointer error When a buffer was exhausted and subsequently reallocated, we could get an unsafe pointer pointing to faulty memory. For this to occur we would need to have a large number of interfaces and a reallocation of memory to a lower addresses. The symptom would be garbage returned from erlang:port_control(Port, 25, []) (prim_inet:getifaddrs(Port) resulting in a badarg) or a segmentation fault. OTP-12446 Application(s): erts Don't close all file descriptors twice in child_setup The commit c2b4eab25c907f453a394d382c04cd04e6c06b49 introduced an error in which child_setup erroneously tried to close all file descriptors twice. Use closefrom() if available when closing all file descriptors. The function closefrom() was only used in the vfork() case before but is now also used in the fork() case if available. OTP-12447 Application(s): erts During a crashdump all file descriptors are closed to ensure the closing of the epmd port and to reserve a file descriptor for the crashdump file. If a driver (third party library) cannot handle closing of sockets this could result in a segmentation fault in which case a crashdump would not be produced. This is now fixed by only closing inets sockets via an emergency close callback to the driver and thus closing the epmd socket. Full runtime dependencies of erts-6.3.1: kernel-3.0, sasl-2.4, stdlib-2.0 --------------------------------------------------------------------- --- inets-5.10.5 ---------------------------------------------------- --------------------------------------------------------------------- The inets-5.10.5 application can be applied independently of other applications on a full OTP 17 installation. --- Fixed Bugs and Malfunctions --- OTP-12436 Application(s): inets Related Id(s): seq12786 mod_alias now handles https-URIs properly Consistent view of configuration parameter keep_alive_timeout, should be presented in the httpd:info/[1,2] function in the same unit as it is inputted. --- Improvements and New Features --- OTP-12429 Application(s): inets Gracefully handle invalid content-lenght headers instead of crashing in list_to_integer. Full runtime dependencies of inets-5.10.5: erts-6.0, kernel-3.0, mnesia-4.12, runtime_tools-1.8.14, ssl-5.3.4, stdlib-2.0 --------------------------------------------------------------------- --------------------------------------------------------------------- --------------------------------------------------------------------- From roger@REDACTED Tue Feb 3 15:06:04 2015 From: roger@REDACTED (Roger Lipscombe) Date: Tue, 3 Feb 2015 14:06:04 +0000 Subject: [erlang-questions] where start the poolboy privately?erlang database connection pools In-Reply-To: References: Message-ID: That question is unlikely to be answered in its current form. However, here are some pointers: My (abandoned-ish) blog engine, https://github.com/rlipscombe/blerg, uses poolboy. - I start poolboy in my application dependencies: https://github.com/rlipscombe/blerg/blob/master/src/blerg.app.src#L11. - The "-s" entry point is here: https://github.com/rlipscombe/blerg/blob/master/src/blerg.erl#L4. - I add poolboy to my supervision tree here: https://github.com/rlipscombe/blerg/blob/master/src/blerg_db_sup.erl#L20 Hope that helps, Roger. On 3 February 2015 at 11:28, ??? <459673409@REDACTED> wrote: > Thank you for reading my question!The URL is: > http://stackoverflow.com/questions/28297708/where-start-the-poolboy-privatelyerlang-database-connection-pools? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From imantc@REDACTED Tue Feb 3 15:39:15 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 3 Feb 2015 15:39:15 +0100 Subject: [erlang-questions] Building erlang R1603-1 on CentOS - unable to load crypto library In-Reply-To: References: <88E44961-52A0-4C30-A0BB-81150AF5AE98@go-factory.net> Message-ID: it is possible to install Erlang with dynamically linked openssl on elliptic curve challenged OS: 1) install openssl ./config --prefix=/usr --openssldir=/usr/local/openssl shared -fPIC make make test sudo make install 2) install Erlang ./configure --prefix /usr --with-ssl-OpenSSL --with-ssl=/usr/include/openssl --enable-dynamic-ssl-lib make sudo make install From luis.rascao@REDACTED Tue Feb 3 15:59:16 2015 From: luis.rascao@REDACTED (=?UTF-8?B?THVpcyBSYXNjw6Nv?=) Date: Tue, 3 Feb 2015 14:59:16 +0000 Subject: [erlang-questions] Building erlang R1603-1 on CentOS - unable to load crypto library In-Reply-To: References: <88E44961-52A0-4C30-A0BB-81150AF5AE98@go-factory.net> Message-ID: btw, worth mentioning again the existence of kerl which is an excellent tool for building the erlang version of your choice https://github.com/yrashk/kerl On Tue, Feb 3, 2015 at 2:39 PM, Imants Cekusins wrote: > it is possible to install Erlang with dynamically linked openssl on > elliptic curve challenged OS: > > 1) install openssl > > ./config --prefix=/usr --openssldir=/usr/local/openssl shared -fPIC > > make > make test > sudo make install > > 2) install Erlang > > ./configure --prefix /usr --with-ssl-OpenSSL > --with-ssl=/usr/include/openssl --enable-dynamic-ssl-lib > > make > sudo make install > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bryan@REDACTED Tue Feb 3 16:37:33 2015 From: bryan@REDACTED (Bryan) Date: Tue, 3 Feb 2015 07:37:33 -0800 Subject: [erlang-questions] Building erlang R1603-1 on CentOS - unable to load crypto library In-Reply-To: References: <88E44961-52A0-4C30-A0BB-81150AF5AE98@go-factory.net> Message-ID: Thanks so much everyone! Really appreciate all the replies and information. Luis, aware of Kerl, unfortunately it is just old habit of building Erlang. Normally it is so trivial. Cheers! Bryan ---- Bryan Hughes Go Factory http://www.go-factory.net Connecting the Internet of Things > On Feb 3, 2015, at 6:59 AM, Luis Rasc?o wrote: > > btw, worth mentioning again the existence of kerl > which is an excellent tool for building the erlang version > of your choice > https://github.com/yrashk/kerl > > On Tue, Feb 3, 2015 at 2:39 PM, Imants Cekusins > wrote: > it is possible to install Erlang with dynamically linked openssl on > elliptic curve challenged OS: > > 1) install openssl > > ./config --prefix=/usr --openssldir=/usr/local/openssl shared -fPIC > > make > make test > sudo make install > > 2) install Erlang > > ./configure --prefix /usr --with-ssl-OpenSSL > --with-ssl=/usr/include/openssl --enable-dynamic-ssl-lib > > make > sudo make install > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ddosia@REDACTED Tue Feb 3 16:49:11 2015 From: ddosia@REDACTED (Daniil Churikov) Date: Tue, 3 Feb 2015 19:49:11 +0400 Subject: [erlang-questions] io:format question Message-ID: Does anybody know why `Format' param of `io:format' and friends disallows `iodata'? I test it and it kinda works (when you do not pass control sequences): 1> io:format("The quick brown fox jumps over the lazy dog~n"). The quick brown fox jumps over the lazy dog ok 2> io:format(["The quick brown fox jumps over the lazy dog~n"]). The quick brown fox jumps over the lazy dog~nok 3> io:format(["The quick brown fox jumps over the lazy dog\n"]). The quick brown fox jumps over the lazy dog ok 4> io:format(["The quick brown fox jumps over the lazy dog: ~p ~p ~n"], [foo, bar]). ** exception error: bad argument in function io:format/3 called as io:format(<0.25.0>, ["The quick brown fox jumps over the lazy dog: ~p ~p ~n"], [foo,bar]) -------------- next part -------------- An HTML attachment was scrubbed... URL: From e@REDACTED Tue Feb 3 16:52:22 2015 From: e@REDACTED (e@REDACTED) Date: Tue, 03 Feb 2015 16:52:22 +0100 Subject: [erlang-questions] io:format question In-Reply-To: References: Message-ID: <54D0EEB6.10205@bestmx.net> On 02/03/2015 04:49 PM, Daniil Churikov wrote: > Does anybody know why `Format' param of `io:format' and friends disallows > `iodata'? allow me to guess: because iodata flattening while during output is a side effect of the output mechanisms . using iodata as "format" argument will require real flattening anyway, rendering its useless. From imantc@REDACTED Tue Feb 3 17:26:45 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 3 Feb 2015 17:26:45 +0100 Subject: [erlang-questions] io:format question In-Reply-To: <54D0EEB6.10205@bestmx.net> References: <54D0EEB6.10205@bestmx.net> Message-ID: isn't it io:format(Format). or io:format(Format, Data). where Format:: format() = atom() | string() | binary() ? it is a bit surprising to see [string()|binary()] accepted for Format in io:format/1. btw [atom()] fails On 3 February 2015 at 16:52, e@REDACTED wrote: > On 02/03/2015 04:49 PM, Daniil Churikov wrote: >> >> Does anybody know why `Format' param of `io:format' and friends disallows >> `iodata'? > > > allow me to guess: > because > iodata flattening while during output is a side effect of the output > mechanisms > . > using iodata as "format" argument will require real flattening anyway, > rendering its useless. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From tuncer.ayaz@REDACTED Tue Feb 3 20:15:55 2015 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Tue, 3 Feb 2015 20:15:55 +0100 Subject: [erlang-questions] Typos in 'getting_started-5.4' In-Reply-To: References: Message-ID: On Tue, Feb 3, 2015 at 4:53 AM, Ted Kaehler wrote: > Folks, > Thank you for your detailed and easy-to-read document, > 'getting_started-5.4'. Here are some corrections. Just search for the > quotation to find it in the document. > > Erlang does not have a string date type > date should be data >From what I can tell, dating back to the R13B03 git sources, this does already say "data type". > The .erlang.cookie file should contain on line with the same atom. > on should be one Fixed by Derek Brown in 069fe154 (Nov 20th 2014). > This example will just show the message passing logic no attempt at all has > been made > something left out after logic? Start a new sentence? In the same commit (069fe154) Derek wrapped this in - ... -, though it seems to be messing a space before the starting '-'. @Derek, want to fix that? > Logs off anybody at at node > at should be that This typo still exists and can be found in three files inside system/doc/getting_started: conc_prog.xml:574:%%% Logs off anybody at at node records_macros.xml:100:%%% Logs off anybody at at node robustness.xml:292:%%% Logs off anybody at at node > Note the use of the spawn_link BIF. > (spawn_link is not actually called in that example.) > > processes mesage queue. > mesage should be message Couldn't find this, but there's a comment typo: erts/emulator/hipe/hipe_bif1.c:162: * size of the mesage[...] > I really appreciate the fact that this document is freely available on the > web! Thanks for all the hard work. Thanks for the report, Ted. For typos like this, if you have a Github account, it's easy to make the corrections directly in your browser and submit a pull request. If you know where to find the sources, that is, and for that it's best to have a local clone of otp.git. Otherwise, someone from the community or the OTP team has to notice and remember to submit a patch. In either case, it's great you took the time to report! From jim.rosenblum@REDACTED Tue Feb 3 22:47:41 2015 From: jim.rosenblum@REDACTED (jim rosenblum) Date: Tue, 3 Feb 2015 16:47:41 -0500 Subject: [erlang-questions] Lager fatal errors when starting an application using erlsrv, but not werl Message-ID: I have an application that uses Lager. I have created packages for Mac OSx, RedHat, Ubuntu and Windows and I have a problem that *only* manifests itself on Windows when my application is started via erlsrv - starting with werl.exe is fine. I register the process via the cmd file produced by Rebar, called jc.cmd in my case. When I start it in a console (i.e., 1> jc.cmd console), all is good, but when I start via '2> jc.cmd start' I get the following errors: 2015-02-03 08:07:31.394 [error] <0.73.0>@lager_handler_watcher:98 Lager fatally failed to install handler lager_console_backend into lager_event, NOT retrying: old_shell 2015-02-03 08:07:31.394 [warning] <0.68.0>@lager_console_backend:64 Lager's console backend is incompatible with the 'old' shell, not enabling it The console command uses werl.exe, the start command uses erlsrv. Can anyone help? thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From sean@REDACTED Wed Feb 4 02:59:40 2015 From: sean@REDACTED (Sean Cribbs) Date: Tue, 3 Feb 2015 17:59:40 -0800 Subject: [erlang-questions] Lager fatal errors when starting an application using erlsrv, but not werl In-Reply-To: References: Message-ID: Hi Jim, When you run headless, there is no console/tty/stdio/etc. In Riak, we solve this using run_erl, which creates UNIX FIFO files that can be attached to separately and replace the standard in/out. I suspect there's nothing similar on Windows and this is the problem you're running into. Unfortunately we don't yet run on Windows. However, we also found console output to have a significant impact on performance in many cases, so in production deploys we generally exclude it and just send it to a file instead. On Tue, Feb 3, 2015 at 1:47 PM, jim rosenblum wrote: > I have an application that uses Lager. I have created packages for Mac > OSx, RedHat, Ubuntu and Windows and I have a problem that *only* manifests > itself on Windows when my application is started via erlsrv - starting with > werl.exe is fine. > > I register the process via the cmd file produced by Rebar, called jc.cmd > in my case. > When I start it in a console (i.e., 1> jc.cmd console), all is good, but > when I start via '2> jc.cmd start' I get the following errors: > > 2015-02-03 08:07:31.394 [error] <0.73.0>@lager_handler_watcher:98 Lager > fatally failed to install handler lager_console_backend into lager_event, > NOT retrying: old_shell > > 2015-02-03 08:07:31.394 [warning] <0.68.0>@lager_console_backend:64 > Lager's console backend is incompatible with the 'old' shell, not enabling > it > > The console command uses werl.exe, the start command uses erlsrv. > > > Can anyone help? > > > thanks > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Sean Cribbs Sr. Software Engineer Basho Technologies, Inc. http://basho.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From 459673409@REDACTED Wed Feb 4 02:51:31 2015 From: 459673409@REDACTED (=?utf-8?B?5pat6IiN56a7?=) Date: Wed, 4 Feb 2015 09:51:31 +0800 Subject: [erlang-questions] =?utf-8?b?5Zue5aSN77yaICB3aGVyZSBzdGFydCB0aGUg?= =?utf-8?q?poolboy_privately=3Ferlangdatabase_connection_pools?= In-Reply-To: References: Message-ID: :) Thanks for your sharing!!Have a nice day! ------------------ ???? ------------------ ???: "Roger Lipscombe";; ????: 2015?2?3?(???) ??10:06 ???: "???"<459673409@REDACTED>; ??: "erlang-questions"; ??: Re: [erlang-questions] where start the poolboy privately?erlangdatabase connection pools That question is unlikely to be answered in its current form. However, here are some pointers: My (abandoned-ish) blog engine, https://github.com/rlipscombe/blerg, uses poolboy. - I start poolboy in my application dependencies: https://github.com/rlipscombe/blerg/blob/master/src/blerg.app.src#L11. - The "-s" entry point is here: https://github.com/rlipscombe/blerg/blob/master/src/blerg.erl#L4. - I add poolboy to my supervision tree here: https://github.com/rlipscombe/blerg/blob/master/src/blerg_db_sup.erl#L20 Hope that helps, Roger. On 3 February 2015 at 11:28, ??? <459673409@REDACTED> wrote: > Thank you for reading my question!The URL is: > http://stackoverflow.com/questions/28297708/where-start-the-poolboy-privatelyerlang-database-connection-pools? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From 459673409@REDACTED Wed Feb 4 08:04:06 2015 From: 459673409@REDACTED (=?utf-8?B?5pat6IiN56a7?=) Date: Wed, 4 Feb 2015 15:04:06 +0800 Subject: [erlang-questions] A problem comes up in my project with mongodb-erlang, cowboy, and poolboy :-) I have tried my best, but no result! Message-ID: Here: http://stackoverflow.com/questions/28315299/why-the-error-function-clause-about-erlang-mongodb-erlang-mongodb? -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim.rosenblum@REDACTED Wed Feb 4 17:10:27 2015 From: jim.rosenblum@REDACTED (Jim Rosenblum) Date: Wed, 4 Feb 2015 11:10:27 -0500 Subject: [erlang-questions] Lager fatal errors when starting an application using erlsrv, but not werl In-Reply-To: References: Message-ID: Thanks, removing the console back end solves my problem. Sent from my iPhone > On Feb 3, 2015, at 8:59 PM, Sean Cribbs wrote: > > Hi Jim, > > When you run headless, there is no console/tty/stdio/etc. In Riak, we solve this using run_erl, which creates UNIX FIFO files that can be attached to separately and replace the standard in/out. I suspect there's nothing similar on Windows and this is the problem you're running into. Unfortunately we don't yet run on Windows. > > However, we also found console output to have a significant impact on performance in many cases, so in production deploys we generally exclude it and just send it to a file instead. > >> On Tue, Feb 3, 2015 at 1:47 PM, jim rosenblum wrote: >> I have an application that uses Lager. I have created packages for Mac OSx, RedHat, Ubuntu and Windows and I have a problem that *only* manifests itself on Windows when my application is started via erlsrv - starting with werl.exe is fine. >> >> I register the process via the cmd file produced by Rebar, called jc.cmd in my case. >> When I start it in a console (i.e., 1> jc.cmd console), all is good, but when I start via '2> jc.cmd start' I get the following errors: >> 2015-02-03 08:07:31.394 [error] <0.73.0>@lager_handler_watcher:98 Lager fatally failed to install handler lager_console_backend into lager_event, NOT retrying: old_shell >> >> 2015-02-03 08:07:31.394 [warning] <0.68.0>@lager_console_backend:64 Lager's console backend is incompatible with the 'old' shell, not enabling it >> >> The console command uses werl.exe, the start command uses erlsrv. >> >> >> >> Can anyone help? >> >> >> >> thanks >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > Sean Cribbs > Sr. Software Engineer > Basho Technologies, Inc. > http://basho.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From esente@REDACTED Thu Feb 5 01:40:21 2015 From: esente@REDACTED (Son Tran-Nguyen) Date: Wed, 4 Feb 2015 18:40:21 -0600 Subject: [erlang-questions] Unity and Erlang In-Reply-To: References: Message-ID: Hi Ivan, I would think that the people who work with Erlang in a day by day basic would not care about C# as much as you, so Unity is not really an interest in them. But as far as I am aware, there is Piko server and its Unityspark Suite ( http://developer.muchdifferent.com/unitypark/uGameDB/architecture) that provides commercial option for Unity. As for personal project, there is this attempt: https://github.com/jordillonch/eggs_unity3d As much as I love making game server in Erlang, Unity is still not a great option for me when it comes to the web platform. I'd just make a web based game if I need to. Sincerely, Son Tran-Nguyen @sntran On Sat, Jan 31, 2015 at 11:52 AM, Ivan Carmenates Garcia < ivan@REDACTED> wrote: > Hi guys, it is nice to be back, to this emailing list, > > I was wondering about an idea, what about a framework to communicate Unity > and Erlang. In the past two or three years, I was posting about a framework > I made, called EVO Extended Visual Otp, which integrated a way to connect > C# and Erlang, very simple and powerful, but unfortunately nobody liked C# > by those days, and I abandoned the project working fine. Now you cannot > imagine my joy when I found out about Unity, I never though that something > like it were even possible to exists, I always dreamed with making games, > and game servers, that why I learned Erlang in the first place, but didn't > knew that game engines with that power even exist!, then I found unity by > accident, and was awesome when I figure out that you can program in it with > C#, my another beloved language, was like a dream came true. > > Now I decided that I want to make EVO for Unity, since I love also Unity > and I'm learn it full, but rebuilding it from scratch since in the old one, > I use otp.net for internal connection between both languages, but now I > want to make it simpler and using pure tcp socket connections to build the > nice EVO layers on top. So I will appreciate any help regard any ways of > low level connections between this two nice languages. > > I saw this > https://coderwall.com/p/gvderg/connecting-unity3d-to-an-erlang-game-server > > and I like, but an extra advice would be appreciated. > > > Best regards, > Ivan. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From 459673409@REDACTED Thu Feb 5 03:30:10 2015 From: 459673409@REDACTED (=?utf-8?B?5pat6IiN56a7?=) Date: Thu, 5 Feb 2015 10:30:10 +0800 Subject: [erlang-questions] Does someone use the IntellijIDEA as the erlang development environement?I just want to kown the answer like the author of the URL.How to link the doc with my-project :0 Message-ID: URL: http://stackoverflow.com/questions/27515951/erlang-plugin-for-intellij-idea-quick-doc-links-for-my-project? -------------- next part -------------- An HTML attachment was scrubbed... URL: From g9414002.pccu.edu.tw@REDACTED Thu Feb 5 06:03:46 2015 From: g9414002.pccu.edu.tw@REDACTED (=?UTF-8?B?6buD6ICA6LOiIChZYXUtSHNpZW4gSHVhbmcp?=) Date: Thu, 5 Feb 2015 13:03:46 +0800 Subject: [erlang-questions] Does someone use the IntellijIDEA as the erlang development environement?I just want to kown the answer like the author of the URL.How to link the doc with my-project :0 In-Reply-To: References: Message-ID: So you want a custom quick doc? It may be about https://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA On Thursday, February 5, 2015, ??? <459673409@REDACTED> wrote: > URL: > http://stackoverflow.com/questions/27515951/erlang-plugin-for-intellij-idea-quick-doc-links-for-my-project ? > -- Best Regards. --- Y-H. H. -------------- next part -------------- An HTML attachment was scrubbed... URL: From 459673409@REDACTED Thu Feb 5 10:05:54 2015 From: 459673409@REDACTED (=?gb18030?B?ts/J4cDr?=) Date: Thu, 5 Feb 2015 17:05:54 +0800 Subject: [erlang-questions] =?gb18030?b?u9i4tKO6ICBEb2VzIHNvbWVvbmUgdXNl?= =?gb18030?q?_the_IntellijIDEA_as_theerlang_development_environement=3FI_j?= =?gb18030?q?ust_want_to_kown_the_answer_like_theauthor_of_the_URL=2EHow_t?= =?gb18030?q?o_link_the_doc_with_my-project_=3A0?= In-Reply-To: References: Message-ID: No,I want this: When i press some key,I can get the function specification.just like java doc. I have tried this way,and someone can get the function information,but i fail ? ------------------ ???? ------------------ ???: "??? (Yau-Hsien Huang)";; ????: 2015?2?5?(???) ??1:03 ???: "???"<459673409@REDACTED>; ??: "erlang-questions"; ??: Re: [erlang-questions] Does someone use the IntellijIDEA as theerlang development environement?I just want to kown the answer like theauthor of the URL.How to link the doc with my-project :0 So you want a custom quick doc? It may be about https://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA On Thursday, February 5, 2015, ??? <459673409@REDACTED> wrote: > URL: > http://stackoverflow.com/questions/27515951/erlang-plugin-for-intellij-idea-quick-doc-links-for-my-project? > -- Best Regards. --- Y-H. H. -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: 38FFF603@REDACTED Type: application/octet-stream Size: 85427 bytes Desc: not available URL: From max.lapshin@REDACTED Thu Feb 5 13:20:05 2015 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 5 Feb 2015 16:20:05 +0400 Subject: [erlang-questions] memsup bug? Message-ID: Context: child_terminated Reason: {badarg,[{erlang,cancel_timer,[undefined],[]},{memsup,handle_info,2,[{file,"memsup.erl"},{line,471}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,599}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]} https://gist.github.com/maxlapshin/9a7b2d86cc1f27f90237 Should I try to patch it and make pull request? -------------- next part -------------- An HTML attachment was scrubbed... URL: From community-manager@REDACTED Thu Feb 5 16:20:58 2015 From: community-manager@REDACTED (Bruce Yinhe) Date: Thu, 5 Feb 2015 16:20:58 +0100 Subject: [erlang-questions] New Erlang job openings Message-ID: Hi, Erlang Central has currently 31 Erlang-related job openings. https://erlangcentral.org/jobs To subscribe for weekly updates on new Erlang jobs - Register on Erlang Central. https://erlangcentral.org/login/?action=register To publish your Erlang job openings free of charge: https://erlangcentral.org/jobs/add *Europe:* UK Home Based Role - Middleware Developer at bet365 - Stoke-on-Trent, UK https://erlangcentral.org/uk-home-based-role-middleware-developer-bet365/ Software Engineer at Ubiquiti Networks - Krakow, Poland https://erlangcentral.org/software-engineer-ubiquiti-networks/ Erlang Developer at Klarna - Stockholm, Sweden https://erlangcentral.org/erlang-developer-klarna/ Erlang developer at IoP - anywhere https://erlangcentral.org/erlang -developer-ambitious-startup-internet-of-people/ Erlang Developer (competitive salary with stock options) at Expend.io - London, UK https://erlangcentral.org/erlang-developer-competitive-salary-with-stock-options-expend-io/ Senior Back-end Engineer at Spatch - London, UK https://erlangcentral.org/senior-back-end-engineer-spatch/ Senior DevOps Engineer at Spatch - London, UK https://erlangcentral.org/senior-devops-engineer-spatch/ Erlang Developer / Generalist at K2 Informatics - Lucerne, Switzerland https://erlangcentral.org/erlang-developer-generalist-k2informatics/ Senior Software Engineer ? Core Tech at DemonWare - Dublin, Ireland https://erlangcentral.org/senior-software-engineer-core-tech-demonware/ Software Engineer - Build Engineering at DemonWare - Dublin, Ireland https://erlangcentral.org/software-engineer-build-engineering-demonware/ Senior Engineer with DevOps Focus at Campanja - Stockholm, Sweden https://erlangcentral.org/senior-engineer-with-devops-focus-campanja/ Backend Engineer at Scycho - Stockholm, Sweden https://erlangcentral.org/backend-engineer-scypho/ Backend Engineer at Centralway - Zurich, Switzerland https://erlangcentral.org/backend-engineer-centralway/ Back-end Developer at NGTI - Rotterdam, The Netherlands https://erlangcentral.org/back-end-developer-ngti-nl/ *Americas:* Software Developer ? Home Based at Basho Technologies - Home Based https://erlangcentral.org/software-developer-home-based-basho/ Principal Software Engineer ? Home Based at Basho Technologies - Home Based https://erlangcentral.org/principal-software-engineer-home-based-basho/ Erlang Developer at Sqor Sports - San Francisco, CA https://erlangcentral.org/erlang-developer-sqor/ Erlang Developer at Inaka - Buenos Aires, Argentina https://erlangcentral.org/erlang-developer-inaka/ Sr. Software Engineer at SynapSense - Folsom, CA https://erlangcentral.org/sr-software-engineer-synapsense/ Senior Software Engineer, Erlang Specialist at AdRoll - San Francisco, CA https://erlangcentral.org/senior-software-engineer-erlang-specialist-adroll/ Backend Engineer at issuu - Palo Alto, CA https://erlangcentral.org/backend-engineer-issuu/ Senior Erlang Engineer at Machine Zone - Palo Alto, CA https://erlangcentral.org/senior-erlang-engineer-machine-zone/ Senior Software Engineer ? Distributed Systems at Couchbase - Mountain View, CA https://erlangcentral.org/senior-software-engineer-distributed-systems-couchbase/ Elixir / Erlang Developer at Vitamin Talent - Austin, Texas (open to remote) https://erlangcentral.org/elixir-erlang-developer-vitamin-talent/ *Asia & Oceania * Software Engineer ? New Grad at ShoreTel - Canberra, Australia https://erlangcentral.org/software-engineer-new-grad-shoretel/ System Analyst (Erlang software engineer) at Chaatz Limited - Wan Chai,Hong Kong https://erlangcentral.org/system-analyst-erlang-software-engineer-chaatz/ Cheers, Bruce Yinhe ErlangCentral.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From e@REDACTED Thu Feb 5 16:53:50 2015 From: e@REDACTED (e@REDACTED) Date: Thu, 05 Feb 2015 16:53:50 +0100 Subject: [erlang-questions] New Erlang job openings In-Reply-To: References: Message-ID: <54D3920E.6070901@bestmx.net> Hi, Bruce. please, clarify the issue: why erlangcentral allows non-erlang jobs to be posted? for example the following are C++ and Java positions: > https://erlangcentral.org/software-engineer-new-grad-shoretel/ > Software Engineer ? New Grad at ShoreTel - Canberra, Australia > https://erlangcentral.org/software-engineer-new-grad-shoretel/ From ingela.andin@REDACTED Thu Feb 5 21:30:11 2015 From: ingela.andin@REDACTED (Ingela Andin) Date: Thu, 5 Feb 2015 21:30:11 +0100 Subject: [erlang-questions] POODLE 2.0 and Erlang In-Reply-To: <1351401782.1208335.1418116897102.JavaMail.zimbra@tpip.net> References: <1351401782.1208335.1418116897102.JavaMail.zimbra@tpip.net> Message-ID: Hi! Just for the record, Google have updated their servers and in 17.5 the padding_check is done for TLS-1.0 again. In OTP 18 SSL-3.0 is disabled by default as are RC4-chiphers. Regards Ingela Erlang/OTP team - Ericsson AB 2014-12-09 10:21 GMT+01:00 Andreas Schultz : > Hi, > > The SSL POODLE attacks is back and this time it affects TLS 1.0: > > https://www.imperialviolet.org/2014/12/08/poodleagain.html > > The blog entry refers to an interesting discussion on TLS WG > maillinglist: > > https://www.ietf.org/mail-archive/web/tls/current/msg14072.html > > It went to check the Erlang SSL stack and it does contain this > comment: > > %% For interoperability reasons we do not check the padding content in > %% SSL 3.0 and TLS 1.0 as it is not strictly required and breaks > %% interopability with for instance Google. > > > In other words, Erlangs TLS 1.0 implementation is 100% RFC compliant > and still vulnerable to a POODLE attack on TLS 1.0. > > For the paranoid, this is a quick fix hack to check padding > bytes on TLS 1.0: > > diff --git a/lib/ssl/src/ssl_cipher.erl b/lib/ssl/src/ssl_cipher.erl > index a6e5e1b..9e23229 100644 > --- a/lib/ssl/src/ssl_cipher.erl > +++ b/lib/ssl/src/ssl_cipher.erl > @@ -1638,8 +1638,7 @@ generic_stream_cipher_from_bin(T, HashSz) -> > %% SSL 3.0 and TLS 1.0 as it is not strictly required and breaks > %% interopability with for instance Google. > is_correct_padding(#generic_block_cipher{padding_length = Len, > - padding = Padding}, {3, N}) > - when N == 0; N == 1 -> > + padding = Padding}, {3, 0}) -> > Len == byte_size(Padding); > %% Padding must be check in TLS 1.1 and after > is_correct_padding(#generic_block_cipher{padding_length = Len, > > Andreas > -- > -- > Dipl. Inform. > Andreas Schultz > _______________________________________________ > 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 Thu Feb 5 22:27:52 2015 From: wallentin.dahlberg@REDACTED (=?UTF-8?Q?Bj=C3=B6rn=2DEgil_Dahlberg?=) Date: Thu, 5 Feb 2015 22:27:52 +0100 Subject: [erlang-questions] memsup bug? In-Reply-To: References: Message-ID: Looks like it but I haven't looked all that hard. The symptom treatment is likely just to check if watchdog timerref is undefined but perhaps there is an underlying cause that should be fixed instead. I think I have two - three PRs on github that I would like to get into 17.5 or 18 but haven't gotten to them yet. I you find the cause and fix it I would appreciate it. os_mon needs some love =) // Bj?rn-Egil 2015-02-05 13:20 GMT+01:00 Max Lapshin : > Context: child_terminated > > Reason: > {badarg,[{erlang,cancel_timer,[undefined],[]},{memsup,handle_info,2,[{file,"memsup.erl"},{line,471}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,599}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]} > > > > https://gist.github.com/maxlapshin/9a7b2d86cc1f27f90237 > > > Should I try to patch it and make pull request? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim.rosenblum@REDACTED Thu Feb 5 22:34:40 2015 From: jim.rosenblum@REDACTED (jim rosenblum) Date: Thu, 5 Feb 2015 16:34:40 -0500 Subject: [erlang-questions] How to have a java/Jinterface node communicate to Erlang nodes using SSL as the connection protocol Message-ID: I have a java application communicating to gen_servers running on a couple of Erlang Nodes. I would like to use SSL as the connection protocol amongst my Erlang nodes, but I see no way to enable the java "nodes" (as exposed via JInterface) to use SSL as the connection protocol. Is this possible? -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Thu Feb 5 22:52:01 2015 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 5 Feb 2015 22:52:01 +0100 Subject: [erlang-questions] How to have a java/Jinterface node communicate to Erlang nodes using SSL as the connection protocol In-Reply-To: References: Message-ID: Hi! There is a pull request for enabling other distribution transports for jinterface https://github.com/erlang/otp/pull/586. It looks ok, but no other transport than the default one is implemented. I suppose it has good chances to be part of OTP 18. regards, Vlad On Thu, Feb 5, 2015 at 10:34 PM, jim rosenblum wrote: > > I have a java application communicating to gen_servers running on a couple > of Erlang Nodes. I would like to use SSL as the connection protocol amongst > my Erlang nodes, but I see no way to enable the java "nodes" (as exposed > via JInterface) to use SSL as the connection protocol. > > Is this possible? > > _______________________________________________ > 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 Feb 6 07:32:50 2015 From: max.lapshin@REDACTED (Max Lapshin) Date: Fri, 6 Feb 2015 10:32:50 +0400 Subject: [erlang-questions] memsup bug? In-Reply-To: References: Message-ID: Ok, I will try to find a test that will reproduce this bug. I'm not sure that I will be able to reproduce it in production, because it is a working video streamer, but at least I have a stacktrace. On Fri, Feb 6, 2015 at 12:27 AM, Bj?rn-Egil Dahlberg < wallentin.dahlberg@REDACTED> wrote: > Looks like it but I haven't looked all that hard. > > The symptom treatment is likely just to check if watchdog timerref is > undefined but perhaps there is an underlying cause that should be fixed > instead. > > I think I have two - three PRs on github that I would like to get into > 17.5 or 18 but haven't gotten to them yet. I you find the cause and fix it > I would appreciate it. os_mon needs some love =) > > // Bj?rn-Egil > > 2015-02-05 13:20 GMT+01:00 Max Lapshin : > >> Context: child_terminated >> >> Reason: >> {badarg,[{erlang,cancel_timer,[undefined],[]},{memsup,handle_info,2,[{file,"memsup.erl"},{line,471}]},{gen_server,handle_msg,5,[{file,"gen_server.erl"},{line,599}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,239}]}]} >> >> >> >> https://gist.github.com/maxlapshin/9a7b2d86cc1f27f90237 >> >> >> Should I try to patch it and make pull request? >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From community-manager@REDACTED Fri Feb 6 10:19:27 2015 From: community-manager@REDACTED (Bruce Yinhe) Date: Fri, 6 Feb 2015 10:19:27 +0100 Subject: [erlang-questions] New Erlang job openings In-Reply-To: <54D3920E.6070901@bestmx.net> References: <54D3920E.6070901@bestmx.net> Message-ID: Hi, Thanks for the email. I appreciate hearing your feedback. Whilst this job might primarily involve C++, it also interfaces towards other Erlang systems. And Erlang is mentioned in the description. We at Erlang Central are working hard to gather all Erlang-related job postings around the world. We have a majority of other postings that solely focused on Erlang. You are more than welcome to check them out at https://erlangcentral.org/jobs. Your applications will be sent directly to the company or their recruiter. And I hope that if there's anything else I can do for you, you won't hesitate to let me know. All the best, Bruce On Thu, Feb 5, 2015 at 4:53 PM, e@REDACTED wrote: > Hi, Bruce. > please, clarify the issue: > why erlangcentral allows non-erlang jobs to be posted? > > for example the following are C++ and Java positions: > > > https://erlangcentral.org/software-engineer-new-grad-shoretel/ > > Software Engineer ? New Grad at ShoreTel - Canberra, Australia >> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Bruce Yinhe Erlang Community Manager Industrial Erlang User Group community-manager@REDACTED +46 72 311 43 89 -------------- next part -------------- An HTML attachment was scrubbed... URL: From derek@REDACTED Thu Feb 5 16:53:38 2015 From: derek@REDACTED (Derek Brown) Date: Thu, 5 Feb 2015 10:53:38 -0500 Subject: [erlang-questions] Typos in 'getting_started-5.4' Message-ID: Ted was referring to the pdf version of Getting Started, at http://www.erlang.org/download/getting_started-5.4.pdf That timestamp on that file is 2004, though, so is out of date with relation to the current HTML guide: http://www.erlang.org/doc/getting_started/intro.html I submitted a PR for a number of the issues that do appear in the current docs. Derek >Date: Tue, 3 Feb 2015 20:15:55 +0100 >From: Tuncer Ayaz >To: Ted Kaehler >Cc: Derek Brown , erlang-questions@REDACTED >Subject: Re: [erlang-questions] Typos in 'getting_started-5.4' >Message-ID: > >Content-Type: text/plain; charset=UTF-8 > >On Tue, Feb 3, 2015 at 4:53 AM, Ted Kaehler wrote: >> Folks, >> Thank you for your detailed and easy-to-read document, >> 'getting_started-5.4'. Here are some corrections. Just search for the >> quotation to find it in the document. >> >> Erlang does not have a string date type >> date should be data > >>From what I can tell, dating back to the R13B03 git sources, this does >already say "data type". > >> The .erlang.cookie file should contain on line with the same atom. >> on should be one > >Fixed by Derek Brown in 069fe154 (Nov 20th 2014). > >> This example will just show the message passing logic no attempt at all has >> been made >> something left out after logic? Start a new sentence? > >In the same commit (069fe154) Derek wrapped this in - ... -, though it >seems to be messing a space before the starting '-'. > >@Derek, want to fix that? > >> Logs off anybody at at node >> at should be that > >This typo still exists and can be found in three files inside >system/doc/getting_started: >conc_prog.xml:574:%%% Logs off anybody at at node >records_macros.xml:100:%%% Logs off anybody at at node >robustness.xml:292:%%% Logs off anybody at at node > >> Note the use of the spawn_link BIF. >> (spawn_link is not actually called in that example.) >> >> processes mesage queue. >> mesage should be message > >Couldn't find this, but there's a comment typo: >erts/emulator/hipe/hipe_bif1.c:162: * size of the mesage[...] > >> I really appreciate the fact that this document is freely available on the >> web! Thanks for all the hard work. > >Thanks for the report, Ted. > >For typos like this, if you have a Github account, it's easy to make >the corrections directly in your browser and submit a pull request. If >you know where to find the sources, that is, and for that it's best to >have a local clone of otp.git. > >Otherwise, someone from the community or the OTP team has to notice >and remember to submit a patch. > >In either case, it's great you took the time to report! -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Fri Feb 6 15:50:55 2015 From: davidnwelton@REDACTED (David Welton) Date: Fri, 6 Feb 2015 15:50:55 +0100 Subject: [erlang-questions] net_kernel:start oddity Message-ID: Node Foo ======== davidw@REDACTED:~ $ erl Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] Eshell V6.3 (abort with ^G) 1> net_kernel:start([foo, longnames]). {ok,<0.35.0>} (foo@REDACTED)2> node(). 'foo@REDACTED' Node Bar ======= davidw@REDACTED:~ $ erl Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] Eshell V6.3 (abort with ^G) 1> net_kernel:start(['bar@REDACTED', longnames]). {ok,<0.35.0>} (bar@REDACTED)2> net_adm:ping('foo@REDACTED'). pang *However*, this works: Node Bar ======= Eshell V6.3 (abort with ^G) 1> net_kernel:start([bar, longnames]). {ok,<0.35.0>} (bar@REDACTED)2> net_adm:ping('foo@REDACTED'). pong I mean, it's the same node, right? net_kernel:start(['bar@REDACTED', longnames]). {ok,<0.45.0>} (bar@REDACTED)6> N1 = node(). 'bar@REDACTED' (bar@REDACTED)7> net_kernel:stop(). ok 8> net_kernel:start([bar, longnames]). {ok,<0.54.0>} (bar@REDACTED)9> N2 = node(). 'bar@REDACTED' (bar@REDACTED)10> N1 == N2. true Any ideas what is going on? -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From derek@REDACTED Fri Feb 6 17:09:47 2015 From: derek@REDACTED (Derek Brown) Date: Fri, 6 Feb 2015 11:09:47 -0500 Subject: [erlang-questions] Updating external references in Erlang docs Message-ID: There are numerous outdated references in the official documentation. For example: http://www.erlang.org/doc/man/os.html#type-0 refers to Solaris 1 and 2, and Windows 95. Solaris 2 was updated by Solaris 7 in 1998, and Windows 95 is from the same period. I've personally made numerous smaller doc changes, but submit for comment more general ones such as these. Derek -------------- next part -------------- An HTML attachment was scrubbed... URL: From shawn@REDACTED Fri Feb 6 17:22:35 2015 From: shawn@REDACTED (Shawn Debnath) Date: Fri, 6 Feb 2015 16:22:35 +0000 Subject: [erlang-questions] Riak Search Production Configuration In-Reply-To: <1162317953.518223.1423237310762.JavaMail.yahoo@mail.yahoo.com> References: <1162317953.518223.1423237310762.JavaMail.yahoo@mail.yahoo.com> Message-ID: I am assuming these are part of a map or some collection for each key. Riak flattens the namespace, so if you have a key KEY1 storing a map called Cyc with fields name, evironment, build; the flattened fields will look similar to Cyc.name, Cyc.environment, Cyc.build. Your schema definition says fields will be strictly ?name?, which is almost never the case. You may want to prefix the name with a ?*?, something like: This is only for simple non-CRDT types. Depending on how you are storing your data, you may need to build an extractor for it. For defined CRDT types, Riak adds their own internal suffixes (_set, _counter, _flag). For CRDTs, I would recommend using the default schema and grep?ing the data files to see what the field names look like (unless someone can recommend a better way) and once you have identified the names, build a custom schema for yourself. Otherwise, use the default schema again, and your custom field definitions above but add an asterisk as the prefix and suffix: "*name*? to see what Riak thinks the full name for that field is. Adding erlang-questions back on, hopefully someone can recommend something for AAE and or correct anything I have said above. On 2/6/15, 7:41 AM, "Nirav Shah" > wrote: Hi Shawn, Here are the schema i am using. If you could share some bit of advice would be great... Also, are there any specific AAE settings that is recommended for Prod systems ? Regards, Nirav ________________________________ From: Shawn Debnath > To: Nirav Shah >; Luc Perkins > Cc: "riak-users@REDACTED" > Sent: Thursday, February 5, 2015 2:14 PM Subject: Re: Riak Search Production Configuration The only thing I can think of is that your flattened full name is not being matched. Also looking at Basho?s default schema, it should be ?_yz_str? and not ?yz_str?, and that only works if you actually have it defined as: in your schema file. The data types for solr are all class names as in solr.*. I would double check your mappings for name, type, and if they are being indexed and stored. If stored is false, you won?t get the data back but you can query on it. On 2/5/15, 2:01 PM, "Nirav Shah" > wrote: Hi Shawn, I am using plain old types. Some of the fields we index ends with Id like execId, verId, orderId and are defined as long. There are some that has random strings which are defined as yz_str. Do you think this fields can cause issues ? Surprisingly, i am seeing some data and some are not present in the Solr. I can understand if no data is found for some field but the fact being i am seeing some data. Also, Is there any suggestions around AAE configuration for production cluster? -Nirav ________________________________ From: Shawn Debnath > To: Nirav Shah >; Luc Perkins > Cc: "riak-users@REDACTED" > Sent: Thursday, February 5, 2015 1:49 PM Subject: Re: Riak Search Production Configuration Nirav, are you using CRDTs or plain old types with Riak? The definition for field names makes a big difference in what gets archived and solr will not complain if it couldn?t find matching fields, it just won?t index them. You can take a peek at the data dir on the Riak instance to see what, if any, is being indexed. On 2/5/15, 12:18 PM, "Nirav Shah" > wrote: Hi Luc, Thanks for the response. Here are the steps i performed on my application start up. I am using the default bucket type in my application 1. Create Custom Schema String schema = Source.fromInputStream(inputStream, "UTF-8").mkString(); (inputStream comes from a schema file that i read) YokozunaSchema yokozunaSchema = new YokozunaSchema("test", schema.toString()); StoreSchema storeSchema = new StoreSchema.Builder(yokozunaSchema).build(); riakClient.execute(storeSchema); 2.Post creation of Schema I created Index for my Object based on the required fields as mentioned in the Riak Search docs and other fields as mapped to my object. I have only few fields set to be Indexed and Stored from my object as i only want to search on them YokozunaIndex yokozunaIndex = new YokozunaIndex("test_idx", "test"); StoreIndex storeIndex = new StoreIndex.Builder(yokozunaIndex).build(); riakClient.execute(storeIndex); 3.Set Bucket Properties I than associate my bucket to the Index as part of the same application start up. Before i attach Index to my bucket, i verify if it has already been attached using a Fetch StoreBucketProperties sbp = new StoreBucketProperties.Builder(namespace) .withAllowMulti(false) .withLastWriteWins(true) .withSearchIndex("test_idx") .build(); riakClient.execute(sbp); Regards, Nirav ________________________________ From: Luc Perkins > To: Nirav Shah > Cc: Shawn Debnath >; "riak-users@REDACTED" > Sent: Thursday, February 5, 2015 11:04 AM Subject: Re: Riak Search Production Configuration Nirav, Could you possibly detail the steps you used to upload the schema, adjust the bucket properties, etc.? That would help us identify the issue. Luc On Thu, Feb 5, 2015 at 9:42 AM, Nirav Shah > wrote: Hi Shawn, Thanks for the response. To give you some background 1. We are using custom schema with default bucket type 2. I have the search set to on:) 3. I have associated BucketProperties/Index to my buckets.. 4. What i am seeing is, i am getting data back, but for some reason i am not getting the entire set. When i query RIAK i see the data, however when i query the solr indexes, its missing that data. At this point, i don't know what can cause this and am looking for people who might have faced similar issues. My default config is just changing search=on in riak.conf, changed the JVM settings in riak.conf for Solr. Would appreciate any pointers and best practice around settings for Riak Search and AAE in production cluster that i should add that folks have running in production cluster. Regards, Nirav ________________________________ From: Shawn Debnath > To: Nirav Shah >; "riak-users@REDACTED" > Sent: Thursday, February 5, 2015 9:13 AM Subject: Re: Riak Search Production Configuration Hi Nirav, About your last point. Just yesterday I started playing with Search 2.0 (solr) and riak. Basho did a good job at integrating the solr platform but docs are sometimes misleading. One thing I found out was the using the default schema provided by Basho, if you are using CRDTs, your fields are suffixed with _register, _counter, _set. This link (http://docs.basho.com/riak/latest/dev/search/search-data-types/) has a good set of examples but best is to experiment. I ended up diving into the data dir of solar and grep?ed for parts of my field names to figure out what it actually was. When running queries, solr/riak will not let you know that fields are incorrect, it just doesn?t have any data for those so it returns no search results. Good luck. Shawn PS. Be sure to have search=on in riak.conf :) On 2/5/15, 7:34 AM, "Nirav Shah" wrote: Hi All, Just wanted to check what kind of configuration settings does everyone use in production clustered environment for Riak Search/AAE and if someone can share some experience over it? We currently have a 2g memory allocated to Solr and are currently just using the default parameters from riak.conf. What we have seen so far is that there is data in RIAK but somehow, Solr/Riak search does not return it. I am trying to find out what can cause this and am i missing some kind of configuration settings. Any response would be appreciated. Regards, Nirav _______________________________________________ riak-users mailing list riak-users@REDACTED http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From shawn@REDACTED Fri Feb 6 17:29:16 2015 From: shawn@REDACTED (Shawn Debnath) Date: Fri, 6 Feb 2015 16:29:16 +0000 Subject: [erlang-questions] Riak Search Production Configuration Message-ID: <366618D1-68B6-4C37-BE14-C299974F4057@debnath.net> Whoops sorry meant for riak-users. On 2/6/15, 8:22 AM, "Shawn Debnath" > wrote: I am assuming these are part of a map or some collection for each key. Riak flattens the namespace, so if you have a key KEY1 storing a map called Cyc with fields name, evironment, build; the flattened fields will look similar to Cyc.name, Cyc.environment, Cyc.build. Your schema definition says fields will be strictly ?name?, which is almost never the case. You may want to prefix the name with a ?*?, something like: This is only for simple non-CRDT types. Depending on how you are storing your data, you may need to build an extractor for it. For defined CRDT types, Riak adds their own internal suffixes (_set, _counter, _flag). For CRDTs, I would recommend using the default schema and grep?ing the data files to see what the field names look like (unless someone can recommend a better way) and once you have identified the names, build a custom schema for yourself. Otherwise, use the default schema again, and your custom field definitions above but add an asterisk as the prefix and suffix: "*name*? to see what Riak thinks the full name for that field is. Adding erlang-questions back on, hopefully someone can recommend something for AAE and or correct anything I have said above. On 2/6/15, 7:41 AM, "Nirav Shah" > wrote: Hi Shawn, Here are the schema i am using. If you could share some bit of advice would be great... Also, are there any specific AAE settings that is recommended for Prod systems ? Regards, Nirav ________________________________ From: Shawn Debnath > To: Nirav Shah >; Luc Perkins > Cc: "riak-users@REDACTED" > Sent: Thursday, February 5, 2015 2:14 PM Subject: Re: Riak Search Production Configuration The only thing I can think of is that your flattened full name is not being matched. Also looking at Basho?s default schema, it should be ?_yz_str? and not ?yz_str?, and that only works if you actually have it defined as: in your schema file. The data types for solr are all class names as in solr.*. I would double check your mappings for name, type, and if they are being indexed and stored. If stored is false, you won?t get the data back but you can query on it. On 2/5/15, 2:01 PM, "Nirav Shah" > wrote: Hi Shawn, I am using plain old types. Some of the fields we index ends with Id like execId, verId, orderId and are defined as long. There are some that has random strings which are defined as yz_str. Do you think this fields can cause issues ? Surprisingly, i am seeing some data and some are not present in the Solr. I can understand if no data is found for some field but the fact being i am seeing some data. Also, Is there any suggestions around AAE configuration for production cluster? -Nirav ________________________________ From: Shawn Debnath > To: Nirav Shah >; Luc Perkins > Cc: "riak-users@REDACTED" > Sent: Thursday, February 5, 2015 1:49 PM Subject: Re: Riak Search Production Configuration Nirav, are you using CRDTs or plain old types with Riak? The definition for field names makes a big difference in what gets archived and solr will not complain if it couldn?t find matching fields, it just won?t index them. You can take a peek at the data dir on the Riak instance to see what, if any, is being indexed. On 2/5/15, 12:18 PM, "Nirav Shah" > wrote: Hi Luc, Thanks for the response. Here are the steps i performed on my application start up. I am using the default bucket type in my application 1. Create Custom Schema String schema = Source.fromInputStream(inputStream, "UTF-8").mkString(); (inputStream comes from a schema file that i read) YokozunaSchema yokozunaSchema = new YokozunaSchema("test", schema.toString()); StoreSchema storeSchema = new StoreSchema.Builder(yokozunaSchema).build(); riakClient.execute(storeSchema); 2.Post creation of Schema I created Index for my Object based on the required fields as mentioned in the Riak Search docs and other fields as mapped to my object. I have only few fields set to be Indexed and Stored from my object as i only want to search on them YokozunaIndex yokozunaIndex = new YokozunaIndex("test_idx", "test"); StoreIndex storeIndex = new StoreIndex.Builder(yokozunaIndex).build(); riakClient.execute(storeIndex); 3.Set Bucket Properties I than associate my bucket to the Index as part of the same application start up. Before i attach Index to my bucket, i verify if it has already been attached using a Fetch StoreBucketProperties sbp = new StoreBucketProperties.Builder(namespace) .withAllowMulti(false) .withLastWriteWins(true) .withSearchIndex("test_idx") .build(); riakClient.execute(sbp); Regards, Nirav ________________________________ From: Luc Perkins > To: Nirav Shah > Cc: Shawn Debnath >; "riak-users@REDACTED" > Sent: Thursday, February 5, 2015 11:04 AM Subject: Re: Riak Search Production Configuration Nirav, Could you possibly detail the steps you used to upload the schema, adjust the bucket properties, etc.? That would help us identify the issue. Luc On Thu, Feb 5, 2015 at 9:42 AM, Nirav Shah > wrote: Hi Shawn, Thanks for the response. To give you some background 1. We are using custom schema with default bucket type 2. I have the search set to on:) 3. I have associated BucketProperties/Index to my buckets.. 4. What i am seeing is, i am getting data back, but for some reason i am not getting the entire set. When i query RIAK i see the data, however when i query the solr indexes, its missing that data. At this point, i don't know what can cause this and am looking for people who might have faced similar issues. My default config is just changing search=on in riak.conf, changed the JVM settings in riak.conf for Solr. Would appreciate any pointers and best practice around settings for Riak Search and AAE in production cluster that i should add that folks have running in production cluster. Regards, Nirav ________________________________ From: Shawn Debnath > To: Nirav Shah >; "riak-users@REDACTED" > Sent: Thursday, February 5, 2015 9:13 AM Subject: Re: Riak Search Production Configuration Hi Nirav, About your last point. Just yesterday I started playing with Search 2.0 (solr) and riak. Basho did a good job at integrating the solr platform but docs are sometimes misleading. One thing I found out was the using the default schema provided by Basho, if you are using CRDTs, your fields are suffixed with _register, _counter, _set. This link (http://docs.basho.com/riak/latest/dev/search/search-data-types/) has a good set of examples but best is to experiment. I ended up diving into the data dir of solar and grep?ed for parts of my field names to figure out what it actually was. When running queries, solr/riak will not let you know that fields are incorrect, it just doesn?t have any data for those so it returns no search results. Good luck. Shawn PS. Be sure to have search=on in riak.conf :) On 2/5/15, 7:34 AM, "Nirav Shah" wrote: Hi All, Just wanted to check what kind of configuration settings does everyone use in production clustered environment for Riak Search/AAE and if someone can share some experience over it? We currently have a 2g memory allocated to Solr and are currently just using the default parameters from riak.conf. What we have seen so far is that there is data in RIAK but somehow, Solr/Riak search does not return it. I am trying to find out what can cause this and am i missing some kind of configuration settings. Any response would be appreciated. Regards, Nirav _______________________________________________ riak-users mailing list riak-users@REDACTED http://lists.basho.com/mailman/listinfo/riak-users_lists.basho.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Fri Feb 6 17:29:41 2015 From: davidnwelton@REDACTED (David Welton) Date: Fri, 6 Feb 2015 17:29:41 +0100 Subject: [erlang-questions] net_kernel:start oddity In-Reply-To: References: Message-ID: > Any ideas what is going on? Straceing the two nodes, there's something odd in what the nodes are sending as part of the handshake. Successful pong sends this initially: 20081 writev(10, [{"\0\27", 2}, {"n\0\5\0\3\177\375foo@REDACTED", 23}], 2) = 25 The pang one (bar) sends this: 20056 writev(12, [{"\0\0\0\23", 4}, {"\0\0\0\2\1\1kiger.buildd\0", 19}], 2) = 23 -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From davidnwelton@REDACTED Fri Feb 6 17:56:28 2015 From: davidnwelton@REDACTED (David Welton) Date: Fri, 6 Feb 2015 17:56:28 +0100 Subject: [erlang-questions] net_kernel:start oddity In-Reply-To: References: Message-ID: I found net_kernel:verbose(10), which gives me, on the 'bad' node: (foo@REDACTED)10> net_kernel:connect_node('bar@REDACTED'). =INFO REPORT==== 6-Feb-2015::17:43:41 === {net_kernel,{connect,normal,'bar@REDACTED'}} =INFO REPORT==== 6-Feb-2015::17:43:41 === {net_kernel,{'EXIT',<0.7660.0>,shutdown}} =INFO REPORT==== 6-Feb-2015::17:43:41 === {net_kernel,{net_kernel,875,nodedown,'bar@REDACTED'}} false On the 'good' node, it works right away: (bar@REDACTED)7> net_kernel:connect_node('foo@REDACTED'). =INFO REPORT==== 6-Feb-2015::17:55:43 === {net_kernel,{connect,normal,'foo@REDACTED'}} true And after that, on the 'pang' node, I can connect to the other node as well... (foo@REDACTED)36> net_kernel:connect_node('bar@REDACTED'). =INFO REPORT==== 6-Feb-2015::17:56:17 === {net_kernel,{connect,normal,'bar@REDACTED'}} true -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From vladdu55@REDACTED Fri Feb 6 18:35:06 2015 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Fri, 6 Feb 2015 18:35:06 +0100 Subject: [erlang-questions] net_kernel:start oddity In-Reply-To: References: Message-ID: Hi David, I'm not sure about this, but I think that the problem is that the node names must be consistent in their use of node names with or without FQDN (in net_kernel:start). The recommended way is to always use it. If my memory serves me right, the issue is traceable to epmd, that saves the node name as received from net_kernel:start, and when you try to connect with a different name, it's not found. In short, always use a node name with a full FQDN when using long names. If anyone knows better, please correct me. best regards, Vlad On Fri, Feb 6, 2015 at 5:56 PM, David Welton wrote: > I found net_kernel:verbose(10), which gives me, on the 'bad' node: > > (foo@REDACTED)10> net_kernel:connect_node('bar@REDACTED'). > > =INFO REPORT==== 6-Feb-2015::17:43:41 === > {net_kernel,{connect,normal,'bar@REDACTED'}} > > =INFO REPORT==== 6-Feb-2015::17:43:41 === > {net_kernel,{'EXIT',<0.7660.0>,shutdown}} > > =INFO REPORT==== 6-Feb-2015::17:43:41 === > {net_kernel,{net_kernel,875,nodedown,'bar@REDACTED'}} > false > > On the 'good' node, it works right away: > > (bar@REDACTED)7> net_kernel:connect_node('foo@REDACTED'). > > =INFO REPORT==== 6-Feb-2015::17:55:43 === > {net_kernel,{connect,normal,'foo@REDACTED'}} > true > > And after that, on the 'pang' node, I can connect to the other node as > well... > (foo@REDACTED)36> net_kernel:connect_node('bar@REDACTED'). > > =INFO REPORT==== 6-Feb-2015::17:56:17 === > {net_kernel,{connect,normal,'bar@REDACTED'}} > true > > > -- > David N. Welton > > http://www.welton.it/davidw/ > > http://www.dedasys.com/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Fri Feb 6 23:27:40 2015 From: davidnwelton@REDACTED (David Welton) Date: Fri, 6 Feb 2015 23:27:40 +0100 Subject: [erlang-questions] net_kernel:start oddity In-Reply-To: References: Message-ID: Hi, > I'm not sure about this, but I think that the problem is that the node names > must be consistent in their use of node names with or without FQDN (in > net_kernel:start). The recommended way is to always use it. If my memory > serves me right, the issue is traceable to epmd, that saves the node name as > received from net_kernel:start, and when you try to connect with a different > name, it's not found. If I do epmd -names, it just shows me: name bar at port 51210 name foo at port 38616 Even though they're registered in different ways. Still though, it does sound plausible. > In short, always use a node name with a full FQDN when using long names. What if you don't know the domain name ahead of time? To me, it seems like there is something behaving oddly. If nothing else, perhaps some additional documentation is needed. http://erlang.org/doc/man/erl.html says that you use the FQDN with -name, but it does work fine without it. http://erlang.org/doc/man/net_kernel.html hints at the fact that the atom you pass it should just be the node name sans the host part. Perhaps that should be made more explicit in the documentation of the start function. Still though, I'm curious what's actually going on underneath to cause the problem I'm seeing. Thanks -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From matthias@REDACTED Sat Feb 7 01:57:04 2015 From: matthias@REDACTED (Matthias Lang) Date: Sat, 7 Feb 2015 01:57:04 +0100 Subject: [erlang-questions] New Erlang job openings In-Reply-To: <54D3920E.6070901@bestmx.net> References: <54D3920E.6070901@bestmx.net> Message-ID: <20150207005704.GA1930@corelatus.se> On 05. February 2015, e@REDACTED wrote: > Hi, Bruce. > please, clarify the issue: > why erlangcentral allows non-erlang jobs to be posted? > > for example the following are C++ and Java positions: > > > https://erlangcentral.org/software-engineer-new-grad-shoretel/ > > >Software Engineer ? New Grad at ShoreTel - Canberra, Australia > >https://erlangcentral.org/software-engineer-new-grad-shoretel/ 1. You've posted the same link twice. 2. The linked text says "The majority of the development work will be in C++ and Erlang." That sounds like an Erlang-related job to me. (Or was it ninja-edited?) Matt (not Bruce) From e@REDACTED Sat Feb 7 04:38:11 2015 From: e@REDACTED (e@REDACTED) Date: Sat, 07 Feb 2015 04:38:11 +0100 Subject: [erlang-questions] New Erlang job openings In-Reply-To: <20150207005704.GA1930@corelatus.se> References: <54D3920E.6070901@bestmx.net> <20150207005704.GA1930@corelatus.se> Message-ID: <54D588A3.7050007@bestmx.net> On 02/07/2015 01:57 AM, Matthias Lang wrote: > On 05. February 2015, e@REDACTED wrote: > >> Hi, Bruce. >> please, clarify the issue: >> why erlangcentral allows non-erlang jobs to be posted? >> >> for example the following are C++ and Java positions: >> >>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >> >>> Software Engineer ? New Grad at ShoreTel - Canberra, Australia >>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ > > 1. You've posted the same link twice. > > 2. The linked text says "The majority of the development work will > be in C++ and Erlang." That sounds like an Erlang-related job to me. > (Or was it ninja-edited?) Candidate description Requirements: Experience with C++ Expertise with ... object-oriented programming Experience with Erlang ... *is a plus* "is a plus" sounds like someone else long time ago has coded something in Erlang and the candidate will be coding C++ whole day long. From e@REDACTED Sat Feb 7 04:43:51 2015 From: e@REDACTED (e@REDACTED) Date: Sat, 07 Feb 2015 04:43:51 +0100 Subject: [erlang-questions] New Erlang job openings In-Reply-To: <20150207005704.GA1930@corelatus.se> References: <54D3920E.6070901@bestmx.net> <20150207005704.GA1930@corelatus.se> Message-ID: <54D589F7.30702@bestmx.net> i have found the missing link https://erlangcentral.org/sr-software-engineer-synapsense/ this is definitely java job Erlang is merely "a plus" On 02/07/2015 01:57 AM, Matthias Lang wrote: > On 05. February 2015, e@REDACTED wrote: > >> Hi, Bruce. >> please, clarify the issue: >> why erlangcentral allows non-erlang jobs to be posted? >> >> for example the following are C++ and Java positions: >> >>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >> >>> Software Engineer ? New Grad at ShoreTel - Canberra, Australia >>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ > > 1. You've posted the same link twice. > > 2. The linked text says "The majority of the development work will > be in C++ and Erlang." That sounds like an Erlang-related job to me. > (Or was it ninja-edited?) > > Matt (not Bruce) > From roberto@REDACTED Sat Feb 7 19:45:12 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Sat, 7 Feb 2015 19:45:12 +0100 Subject: [erlang-questions] Mnesia create tables best practices Message-ID: Dear list, What best practice do you have when you have a release and want to insure a node has a properly initialised mnesia scheme? Do you manually bring up all the nodes, then ping them, then go through a standard function which creates schemas and tables, then you shut down your nodes and start your release on the nodes? Do you instead have a function which check whether mnesia is already initialised every time you start a release? In which case, how do you determine which is the "master" node that will perform the table creation? Just curious. Until now I have done it with an additional nodetool call that can manually be started with a /myapp/bin/myapp install_db kind of call, but I would like to see if there is a best practice to have it done "automagically". :) r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From harit.subscriptions@REDACTED Sun Feb 8 05:52:46 2015 From: harit.subscriptions@REDACTED (Harit Himanshu) Date: Sat, 7 Feb 2015 20:52:46 -0800 Subject: [erlang-questions] Question on building a Parallel Server In-Reply-To: References: Message-ID: Thanks @Joe, makes more sense. so as I read the process that creates the Socket is controlling process. When controlling process is killed, the Socket is closed. My question is following 1. How does killing of controlling process affect the process owned by Listen 2. If we reverse this approach, how does killing of process (which owns Listen) affects n controlling processes (for n different Sockets associated with this Listen process)? Thanks a lot + Harit Himanshu On Tue, Jan 27, 2015 at 10:48 AM, Joe Armstrong wrote: > On Tue, Jan 27, 2015 at 2:43 PM, Harit Himanshu > wrote: > > Hello > > > > As I learn from Programming Erlang, the following is a way to create a > > parallel server > > > > start_parallel_server() -> > > {ok, Listen} = gen_tcp:listen(...), spawn(fun() -> par_connect(Listen) > end). > > > > par_connect(Listen) -> > > {ok, Socket} = gen_tcp:accept(Listen), spawn(fun() -> par_connect(Listen) > > end), loop(Socket). > > > > > > I wanted to dissect this code to understand what's going on. > > > > Questions > > > > When we call start_parallel_server() on a single machine, a separate > > process is started (which is controlling process?) executing par_connect, > > correct? > > When gen_tcp:accept accepts a new connection, immediately a new process > is > > created executing par_connect(Listen). This makes sure that we can accept > > more requests from the client. Now who is the controlling process for > this > > new process? is the same as Listen? > > no > > Listen is owned by the process that called gen_tcp:listen > Socket is owned by the process that called gen_tcp:accept > > So you end up with one Listen process and N different values of > Socket (one per spawned process). Each parallel process has it's own socket > > /Joe > > > > > > > > Thanks > > + Harit Himanshu > > > > > > _______________________________________________ > > erlang-questions mailing list > > erlang-questions@REDACTED > > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben@REDACTED Sun Feb 8 10:48:11 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Sun, 08 Feb 2015 10:48:11 +0100 Subject: [erlang-questions] second try for understanding recursion Message-ID: <54D730DB.5080804@home.nl> Hello, I have studied recursion the last few weeks by using Haskell and I think I understand it. I did a portion of this exercise : Write a module boolean.erlthat takes logical expressions and Boolean values (represented as the atoms trueand false) and returns their Boolean result. The functions you write should include b_not/1, b_and/2, b_or/2, and b_nand/2. You should not use the logical constructs and, or, and not, but instead use pattern matching to achieve your goal. so far I have this : -module(boolean). -export([b_not/1]). % if a empty string is given , the answer will be a empty string. b_not('') -> ''; % is false is given, the answer will be true. b_not(false) -> true; % is true is given, the answer will be false b_not(true) -> false. Is this a good try or can I change anything ? Roelof From tony@REDACTED Sun Feb 8 12:34:56 2015 From: tony@REDACTED (Tony Rogvall) Date: Sun, 8 Feb 2015 12:34:56 +0100 Subject: [erlang-questions] second try for understanding recursion In-Reply-To: <54D730DB.5080804@home.nl> References: <54D730DB.5080804@home.nl> Message-ID: <5BF3CF0A-91D2-4AAC-A144-201B8C9D19FA@rogvall.se> Deja vu? I thought you already completed this exercise ? Have you started reading the book I hinted about? BR /Tony > On 8 feb 2015, at 10:48, Roelof Wobben wrote: > > Hello, > > I have studied recursion the last few weeks by using Haskell and I think I understand it. > > I did a portion of this exercise : > > Write a module boolean.erlthat takes logical expressions and Boolean values (represented as the atoms trueand false) and returns their Boolean result. The functions > you write should include b_not/1, b_and/2, b_or/2, and b_nand/2. You should not use > the logical constructs and, or, and not, but instead use pattern matching to achieve your > goal. > > so far I have this : > > -module(boolean). > > -export([b_not/1]). > > % if a empty string is given , the answer will be a empty string. > b_not('') -> > ''; > > % is false is given, the answer will be true. > b_not(false) -> > true; > > % is true is given, the answer will be false > b_not(true) -> > false. > > Is this a good try or can I change anything ? > > Roelof > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 801 bytes Desc: Message signed with OpenPGP using GPGMail URL: From eriksoe@REDACTED Sun Feb 8 12:44:17 2015 From: eriksoe@REDACTED (=?UTF-8?Q?Erik_S=C3=B8e_S=C3=B8rensen?=) Date: Sun, 8 Feb 2015 12:44:17 +0100 Subject: [erlang-questions] second try for understanding recursion In-Reply-To: <54D730DB.5080804@home.nl> References: <54D730DB.5080804@home.nl> Message-ID: OK, I have a few comments: - why handle '' in your implementation of not ? I get the suspicion that either you've been exposed to some other language where there was some special value to always have to handle, or that you've been looking for inspiration in some string-related recursion examples? (Bonus question: how would your implementation of not in Haskell look like? Would it have three clauses? ) - '' is not a string, but an atom. They are different beasts. - so far, there's no recursion at all. Nor would you need recursion for implementing not, or, and etc. Why are you asking questions before you get to the recursion part, in a post mentioning recursion in the title? (You are allowed to, of course, but the rest of us are allowed to be confused by it :-)) As I understand the task, it is about writing a module which literally takes (representations of) boolean expressions, such as "true AND (false OR true)" and calculates the result. That does require recursion (as well as choosing a suitable data structure for representing expressions). Starting with the functions mentioned in the task description, as you have dine, sounds like a good idea, though. - Finally: there are two parts to good code: 1) does it work and 2) is it well written. (Well, also 1b) how little does it take to make it stop working.) For 2), this mailing list can be a good source of help. But 1) you can do yourself - you could eg add a test function to your module: test () -> false = b_not(true), %... other test cases... ok. A side effect of this is signalling your level of understanding in mailing list posts, improving the chance of answers at the right level. (It may be clear at this point that I don't really know at which level to reply...) Hoping this helps somehow /Erik Den 08/02/2015 11.56 skrev "Roelof Wobben" : > Hello, > > I have studied recursion the last few weeks by using Haskell and I think I > understand it. > > I did a portion of this exercise : > > Write a module boolean.erlthat takes logical expressions and Boolean > values (represented as the atoms trueand false) and returns their Boolean > result. The functions > you write should include b_not/1, b_and/2, b_or/2, and b_nand/2. You > should not use > the logical constructs and, or, and not, but instead use pattern > matching to achieve your > goal. > > so far I have this : > > -module(boolean). > > -export([b_not/1]). > > % if a empty string is given , the answer will be a empty string. > b_not('') -> > ''; > > % is false is given, the answer will be true. > b_not(false) -> > true; > > % is true is given, the answer will be false > b_not(true) -> > false. > > Is this a good try or can I change anything ? > > Roelof > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric@REDACTED Sun Feb 8 12:38:44 2015 From: eric@REDACTED (eric) Date: Sun, 08 Feb 2015 12:38:44 +0100 Subject: [erlang-questions] second try for understanding recursion In-Reply-To: <54D730DB.5080804@home.nl> References: <54D730DB.5080804@home.nl> Message-ID: <54D74AC4.8070404@pagefault.se> Hey! I think it looks good. However I don't see the point of handling the empty string as you do here. > -export([b_not/1]). > > % if a empty string is given , the answer will be a empty string. > b_not('') -> > ''; As I read the exercise there's no need to handle it, but maybe I'm missing something? // Eric From r.wobben@REDACTED Sun Feb 8 13:36:11 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Sun, 08 Feb 2015 13:36:11 +0100 Subject: [erlang-questions] second try for understanding recursion In-Reply-To: References: <54D730DB.5080804@home.nl> Message-ID: <54D7583B.6040904@home.nl> An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Sun Feb 8 16:35:57 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sun, 8 Feb 2015 16:35:57 +0100 Subject: [erlang-questions] Question on building a Parallel Server In-Reply-To: References: Message-ID: On Sun, Feb 8, 2015 at 5:52 AM, Harit Himanshu < harit.subscriptions@REDACTED> wrote: > My question is following > > 1. How does killing of controlling process affect the process owned by > Listen > 2. If we reverse this approach, how does killing of process (which > owns Listen) affects n controlling processes (for n different Sockets > associated with this Listen process)? > > The ListenSock has a ListenProcess. An AcceptProcess calling {ok, ASock} = gen_tcp:accept(ListenSock) creates a new socket, ASock. The control rules are: ListenProcess controls ListenSock AcceptProcess controls ASock Termination of ListenProcess will affect the socket directly under its control, ListenSock, but will not touch ASock. Vice versa, termination of AcceptProcess will close ASock, but not affect ListenSock in any way. In other words, the two sockets bear no relation to each other, other than one was used to create the other. There are some caveats to look out for, however. Often, you run the Listener in one process, away from workers since it protects the system. And error in one part doesn't affect the other part. Once a listen socket closes, the operating system doesn't let you reuse that socket immediately, but imposes a "linger time" in which you can't rebind to the Address/Port combination. The reason for the lingering is to make sure drain happens such that you don't inadvertedly connect up incorrectly. You may want to enable the SO_REUSEADDR socket option, which is done in Erlang by creating the listen socket with the {reuseaddr, true} option. It does other things than just solve the lingering problem however, and exactly what it does is OS dependent. The best solution is to trust the ListenProcess more than the workers. That is, place the ListenProcess higher up in the supervisor tree and make its death be fatal to the system. If the operating system suddenly denies you access to the Listen socket, chances are you have a major problem. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vladdu55@REDACTED Sun Feb 8 16:45:14 2015 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Sun, 8 Feb 2015 16:45:14 +0100 Subject: [erlang-questions] net_kernel:start oddity In-Reply-To: References: Message-ID: On Fri, Feb 6, 2015 at 11:27 PM, David Welton wrote: > > > In short, always use a node name with a full FQDN when using long names. > > What if you don't know the domain name ahead of time? To me, it seems > like there is something behaving oddly. If nothing else, perhaps some > additional documentation is needed. > For me (I am using a mixed Erlang+Java environment) the problem was (and still is) that different tools (Erlang and Java, in this case) resolve names slightly differently, causing problems. I am solving this by simply trying to start with different arguments and see which one works. It's not nice, but I couldn't find any other way that would work for everybody. > Still though, I'm curious what's actually going on underneath to cause > the problem I'm seeing. > Did you try to run epmd with the debug flag and check what exactly is sent over the wire? regards, Vlad -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Sun Feb 8 16:47:38 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sun, 8 Feb 2015 16:47:38 +0100 Subject: [erlang-questions] Mnesia create tables best practices In-Reply-To: References: Message-ID: On Sat, Feb 7, 2015 at 7:45 PM, Roberto Ostinelli wrote: > Dear list, > What best practice do you have when you have a release and want to insure > a node has a properly initialised mnesia scheme? > Provide a pre-initialized database with your release. Don't attempt "figuring out" if there is no database and then create it on demand. It just leads to misery. Your system proper only operates if there is a database. The End. When the release initially boots, there is a complete database, with a complete schema, ready to run, so the nodes can start working immediately. Some times, you will me using a method, where there is a file named FALLBACK.BUP. This is a "fallback" file, which will "restore" the database once the system is booted. This is also how `mnesia:create_schema/2` works, incidentally :P The beauty of this way is that your system is always in a state where it is "catching up" from a known good state. And you don't have to handle the special case of "initializing", which is completely perpendicular to your normal operation. Unfortunately, creation of Mnesia databases is not an idempotent operation. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From e@REDACTED Sun Feb 8 17:21:10 2015 From: e@REDACTED (e@REDACTED) Date: Sun, 08 Feb 2015 17:21:10 +0100 Subject: [erlang-questions] Mnesia create tables best practices In-Reply-To: References: Message-ID: <54D78CF6.1070809@bestmx.net> > Provide a pre-initialized database with your release. Don't attempt > "figuring out" if there is no database and then create it on demand. It > just leads to misery. can't help giving you my thanks. lots of thanks. > Your system proper only operates if there is a database. The End. When the > release initially boots, there is a complete database, with a complete > schema, ready to run, so the nodes can start working immediately. Some > times, you will me using a method, where there is a file named > FALLBACK.BUP. This is a "fallback" file, which will "restore" the database > once the system is booted. This is also how `mnesia:create_schema/2` works, > incidentally :P > > The beauty of this way is that your system is always in a state where it is > "catching up" from a known good state. And you don't have to handle the > special case of "initializing", which is completely perpendicular to your > normal operation. > > Unfortunately, creation of Mnesia databases is not an idempotent operation. From harit.subscriptions@REDACTED Sun Feb 8 18:25:21 2015 From: harit.subscriptions@REDACTED (Harit Himanshu) Date: Sun, 8 Feb 2015 09:25:21 -0800 Subject: [erlang-questions] Question on building a Parallel Server In-Reply-To: References: Message-ID: Thanks @Jesper for detailed explanation + Harit On Sun, Feb 8, 2015 at 7:35 AM, Jesper Louis Andersen < jesper.louis.andersen@REDACTED> wrote: > > On Sun, Feb 8, 2015 at 5:52 AM, Harit Himanshu < > harit.subscriptions@REDACTED> wrote: > >> My question is following >> >> 1. How does killing of controlling process affect the process owned >> by Listen >> 2. If we reverse this approach, how does killing of process (which >> owns Listen) affects n controlling processes (for n different Sockets >> associated with this Listen process)? >> >> > The ListenSock has a ListenProcess. An AcceptProcess calling {ok, ASock} = > gen_tcp:accept(ListenSock) creates a new socket, ASock. The control rules > are: > > ListenProcess controls ListenSock > AcceptProcess controls ASock > > Termination of ListenProcess will affect the socket directly under its > control, ListenSock, but will not touch ASock. Vice versa, termination of > AcceptProcess will close ASock, but not affect ListenSock in any way. In > other words, the two sockets bear no relation to each other, other than one > was used to create the other. > > There are some caveats to look out for, however. Often, you run the > Listener in one process, away from workers since it protects the system. > And error in one part doesn't affect the other part. Once a listen socket > closes, the operating system doesn't let you reuse that socket immediately, > but imposes a "linger time" in which you can't rebind to the Address/Port > combination. The reason for the lingering is to make sure drain happens > such that you don't inadvertedly connect up incorrectly. You may want to > enable the SO_REUSEADDR socket option, which is done in Erlang by creating > the listen socket with the {reuseaddr, true} option. It does other things > than just solve the lingering problem however, and exactly what it does is > OS dependent. > > The best solution is to trust the ListenProcess more than the workers. > That is, place the ListenProcess higher up in the supervisor tree and make > its death be fatal to the system. If the operating system suddenly denies > you access to the Listen socket, chances are you have a major problem. > > > > -- > J. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuncer.ayaz@REDACTED Sun Feb 8 18:29:21 2015 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Sun, 8 Feb 2015 18:29:21 +0100 Subject: [erlang-questions] net_kernel:start oddity In-Reply-To: References: Message-ID: On Fri, Feb 6, 2015 at 11:27 PM, David Welton wrote: > Hi, > > > I'm not sure about this, but I think that the problem is that the > > node names must be consistent in their use of node names with or > > without FQDN (in net_kernel:start). The recommended way is to > > always use it. If my memory serves me right, the issue is > > traceable to epmd, that saves the node name as received from > > net_kernel:start, and when you try to connect with a different > > name, it's not found. > > If I do epmd -names, it just shows me: > > name bar at port 51210 > name foo at port 38616 > > Even though they're registered in different ways. > > Still though, it does sound plausible. > > > In short, always use a node name with a full FQDN when using long names. > > What if you don't know the domain name ahead of time? To me, it > seems like there is something behaving oddly. If nothing else, > perhaps some additional documentation is needed. > > http://erlang.org/doc/man/erl.html says that you use the FQDN with > -name, but it does work fine without it. > > http://erlang.org/doc/man/net_kernel.html hints at the fact that the > atom you pass it should just be the node name sans the host part. > Perhaps that should be made more explicit in the documentation of > the start function. > > Still though, I'm curious what's actually going on underneath to > cause the problem I'm seeing. You might try tracing net_kernel:create_hostpart/2 plus inet_db:gethostname/0 and continue from there. From roberto.ostinelli@REDACTED Sun Feb 8 19:25:17 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Sun, 8 Feb 2015 19:25:17 +0100 Subject: [erlang-questions] Mnesia create tables best practices In-Reply-To: References: Message-ID: <87467EDF-C075-4F77-8993-C4108D2432A6@widetag.com> > Some times, you will me using a method, where there is a file named FALLBACK.BUP. This is a "fallback" file, which will "restore" the database once the system is booted. This is also how `mnesia:create_schema/2` works, incidentally :P > > The beauty of this way is that your system is always in a state where it is "catching up" from a known good state. And you don't have to handle the special case of "initializing", which is completely perpendicular to your normal operation. Thank you Jesper. That makes a lot of sense. Can you please expand on this? Do you mean that when you boot a system you reset the db? Best, r. From p.wycisk@REDACTED Sun Feb 8 19:25:34 2015 From: p.wycisk@REDACTED (=?UTF-8?Q?Przemys=C5=82aw_Wycisk?=) Date: Sun, 8 Feb 2015 19:25:34 +0100 Subject: [erlang-questions] erlang http tcp_closed problem Message-ID: I've got problem with using erlang active http socket. I receive msgs like that: ok = inet:setopts(Sock,[{active, true}]), receive {http, Sock, {http_request, HttpMethod, {abs_path, Path}, _HttpVersion}} -> Headers = getHeaders(Sock), %more code and then headers like that: getHeaders(Sock, Headers) -> receive {http, Sock, {http_header, _Num, 'Content-Length', _, Value}} -> NewHeaders = Headers#'headers'{contentLength = Value}, getHeaders(Sock, NewHeaders); {http, Sock, {http_header, _Num, 'Host', _, Value}} -> NewHeaders = Headers#'headers'{host = Value}, getHeaders(Sock, NewHeaders); {http, Sock, {http_header, _Num, 'User-Agent', _, Value}} -> NewHeaders = Headers#'headers'{userAgent = Value}, getHeaders(Sock, NewHeaders); %more headers here % {http, Sock, {http_error, Error}} -> ?LOG_INFO("protocol", "http returned error with reason:~p~n", [Error]), exit(normal); {http, Sock, http_eoh} -> Headers; {tcp_closed, Sock} -> % ?LOG_INFO("connection", "Socket ~w closed by client", [Sock]), exit(normal); _Else -> getHeaders(Sock, Headers) end. Normally it works fine, packets and headers are received from browser and everyone is happy, but there is a case, when a browser sends a request, and then i get "tcp_closed" in place where is placed, in the middle of receiving headers. This behaviour is strange for me, because it never happens in incognito mode. That could mean that bowsers cache is involved in the problem, but how? Anyone had the same problem? Anyone could help? I would be grateful. -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Sun Feb 8 20:56:01 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Sun, 8 Feb 2015 20:56:01 +0100 Subject: [erlang-questions] Distributed Process Registry Message-ID: Dear list, I have 3 interconnected nodes to which various devices connect to. Once a device connects to one of those nodes, the related TCP socket events are handled by a device_loop process on the node that it originally connected to. Every device is identified via its id (a binary). I need to enable communication from one device to the other based on these ids, even within different nodes. I have around 150k device processes per node (so up to 500k in total). So, I basically need a global process registry. Not new, but haven't used one in a while now. As far as I can tell, my main options to send messages from one device process to the other based on their id are the erlang global module, ulf's gproc, or implement a custom solution based on, for instance, mnesia in ram only. I was first thinking of leaning towards using the erlang global module, since register_name/2,3 now also allows general terms to be used as Name. The advantages I see: - It is a simple built-in mechanism. - If a node goes down, the global names registered on that node are unregistered automatically. - If a new node is added, the global names registered are propagated automatically. The cons: - I always feel that process registration should be used to identify long-running services. - I don't know if 500k is an acceptable number (i.e. if the global module is made to support my use case). I also looked into gproc. The advantages I see: - Actively maintained, it seems to have been built for my use case. The cons: - For the distributed part it relies on gen_leader. I've heard too many horror stories on gen_leader. Maybe that's not a thing anymore. - Not sure what happens if a node goes down / a new node is added. I've considered a custom solution based on mnesia distributed ram-only tables that would store the pids of the device loops based on their binary id.The advantages I see: - Mnesia will take care of distributing, handling down events, etc. The cons: - I need to reinvent the wheel and ensure that when a node goes down, all the device entries in the distributed mnesia tables related to that node are removed. Has someone recently implemented a distributed process registry and can shed some light for me? Thank you in advance for your advice ^^_ r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Sun Feb 8 21:38:13 2015 From: ulf@REDACTED (Ulf Wiger) Date: Sun, 8 Feb 2015 21:38:13 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: Message-ID: > On 08 Feb 2015, at 20:56, Roberto Ostinelli wrote: > > For the distributed part it relies on gen_leader. I've heard too many horror stories on gen_leader. Maybe that's not a thing anymore. Personally, I?m putting my energy into locks_leader rather than gen_leader. There is a gproc branch that uses locks_leader [1], and I?m willing to support it (OSS-style, that is, best-effort unless someone actually pays me). I?d love to make the locks_leader version the main track for distributed gproc, but am hoping for field reports from people actually using locks_leader in anger. [1] https://github.com/uwiger/gproc/tree/uw-locks_leader BR, Ulf W Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. http://feuerlabs.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Sun Feb 8 21:51:52 2015 From: mjtruog@REDACTED (Michael Truog) Date: Sun, 08 Feb 2015 12:51:52 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: Message-ID: <54D7CC68.4010105@gmail.com> On 02/08/2015 11:56 AM, Roberto Ostinelli wrote: > Dear list, > I have 3 interconnected nodes to which various devices connect to. > Once a device connects to one of those nodes, the related TCP socket events are handled by a device_loop process on the node that it originally connected to. > > Every device is identified via its id (a binary). I need to enable communication from one device to the other based on these ids, even within different nodes. I have around 150k device processes per node (so up to 500k in total). > > So, I basically need a global process registry. Not new, but haven't used one in a while now. > > As far as I can tell, my main options to send messages from one device process to the other based on their id are the erlang global module, ulf's gproc, or implement a custom solution based on, for instance, mnesia in ram only. > > > I was first thinking of leaning towards using the erlang global module, since register_name/2,3 now also allows general terms to be used as Name. The advantages I see: > > * It is a simple built-in mechanism. > * If a node goes down, the global names registered on that node are unregistered automatically. > * If a new node is added, the global names registered are propagated automatically. > > The cons: > > * I always feel that process registration should be used to identify long-running services. > * I don't know if 500k is an acceptable number (i.e. if the global module is made to support my use case). > > > I also looked into gproc. The advantages I see: > > * Actively maintained, it seems to have been built for my use case. > > The cons: > > * For the distributed part it relies on gen_leader. I've heard too many horror stories on gen_leader. Maybe that's not a thing anymore. > * Not sure what happens if a node goes down / a new node is added. > > > I've considered a custom solution based on mnesia distributed ram-only tables that would store the pids of the device loops based on their binary id.The advantages I see: > > * Mnesia will take care of distributing, handling down events, etc. > > The cons: > > * I need to reinvent the wheel and ensure that when a node goes down, all the device entries in the distributed mnesia tables related to that node are removed. > > > > Has someone recently implemented a distributed process registry and can shed some light for me? > > Thank you in advance for your advice ^^_ > r. > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions You are missing a few options: http://www.erlang.org/doc/man/pg2.html * Any term can be used for a name https://github.com/okeuday/cpg/ * By default uses string (list of integer) names, but can be changed with group_storage application env setting (e.g., to dict) * Supports any number of scopes, which are atoms that are used as locally registered cpg process identifiers (pg2 only supports the single global scope stored in ETS) * Supports the via syntax, like gproc does, with variations that allow pools to be created (https://github.com/okeuday/cpg/blob/master/test/cpg_test.erl#L83-L104) Both pg2 and cpg allow you to avoid centralized global state (the state used in gproc, locks_leader, mnesia, global) so that netsplits do not require an arbitrary process to resolve state conflicts. That is very important for reliability. -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto.ostinelli@REDACTED Sun Feb 8 21:59:48 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Sun, 8 Feb 2015 21:59:48 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <54D7CC68.4010105@gmail.com> References: <54D7CC68.4010105@gmail.com> Message-ID: <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> Hello Michael, I know of those but I've left them out as I do not need group mechanisms: I'm not interested in broadcasting messages to multiple devices. Just a 1-to-1 messaging. Is there any reason why using these process groups be beneficial in my use case? Thank you for your input, r. > On 08/feb/2015, at 21:51, Michael Truog wrote: > >> On 02/08/2015 11:56 AM, Roberto Ostinelli wrote: >> Dear list, >> I have 3 interconnected nodes to which various devices connect to. >> Once a device connects to one of those nodes, the related TCP socket events are handled by a device_loop process on the node that it originally connected to. >> >> Every device is identified via its id (a binary). I need to enable communication from one device to the other based on these ids, even within different nodes. I have around 150k device processes per node (so up to 500k in total). >> >> So, I basically need a global process registry. Not new, but haven't used one in a while now. >> >> As far as I can tell, my main options to send messages from one device process to the other based on their id are the erlang global module, ulf's gproc, or implement a custom solution based on, for instance, mnesia in ram only. >> >> >> I was first thinking of leaning towards using the erlang global module, since register_name/2,3 now also allows general terms to be used as Name. The advantages I see: >> It is a simple built-in mechanism. >> If a node goes down, the global names registered on that node are unregistered automatically. >> If a new node is added, the global names registered are propagated automatically. >> The cons: >> I always feel that process registration should be used to identify long-running services. >> I don't know if 500k is an acceptable number (i.e. if the global module is made to support my use case). >> >> I also looked into gproc. The advantages I see: >> Actively maintained, it seems to have been built for my use case. >> The cons: >> For the distributed part it relies on gen_leader. I've heard too many horror stories on gen_leader. Maybe that's not a thing anymore. >> Not sure what happens if a node goes down / a new node is added. >> >> I've considered a custom solution based on mnesia distributed ram-only tables that would store the pids of the device loops based on their binary id.The advantages I see: >> Mnesia will take care of distributing, handling down events, etc. >> The cons: >> I need to reinvent the wheel and ensure that when a node goes down, all the device entries in the distributed mnesia tables related to that node are removed. >> >> >> Has someone recently implemented a distributed process registry and can shed some light for me? >> >> Thank you in advance for your advice ^^_ >> r. >> >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > You are missing a few options: > > http://www.erlang.org/doc/man/pg2.html > * Any term can be used for a name > > https://github.com/okeuday/cpg/ > * By default uses string (list of integer) names, but can be changed with group_storage application env setting (e.g., to dict) > * Supports any number of scopes, which are atoms that are used as locally registered cpg process identifiers (pg2 only supports the single global scope stored in ETS) > * Supports the via syntax, like gproc does, with variations that allow pools to be created (https://github.com/okeuday/cpg/blob/master/test/cpg_test.erl#L83-L104) > > Both pg2 and cpg allow you to avoid centralized global state (the state used in gproc, locks_leader, mnesia, global) so that netsplits do not require an arbitrary process to resolve state conflicts. That is very important for reliability. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Sun Feb 8 22:10:14 2015 From: mjtruog@REDACTED (Michael Truog) Date: Sun, 08 Feb 2015 13:10:14 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> Message-ID: <54D7D0B6.3090901@gmail.com> On 02/08/2015 12:59 PM, Roberto Ostinelli wrote: > Hello Michael, > I know of those but I've left them out as I do not need group mechanisms: I'm not interested in broadcasting messages to multiple devices. Just a 1-to-1 messaging. That usage of pg2 and cpg just means that you would only have a single pid in a group. It might seem a bit different, but I don't think there is a better alternative. > > Is there any reason why using these process groups be beneficial in my use case? The main reason is that you avoid the need to resolve state conflicts when global state gets merged after a netsplit. With pg2 and cpg, all the state relevant to the local node is stored locally and remote state gets merged as nodes are added. When a node dies, its pids are removed, as expected, but there is no need for centralized global state. > > Thank you for your input, > r. > > > > On 08/feb/2015, at 21:51, Michael Truog > wrote: > >> On 02/08/2015 11:56 AM, Roberto Ostinelli wrote: >>> Dear list, >>> I have 3 interconnected nodes to which various devices connect to. >>> Once a device connects to one of those nodes, the related TCP socket events are handled by a device_loop process on the node that it originally connected to. >>> >>> Every device is identified via its id (a binary). I need to enable communication from one device to the other based on these ids, even within different nodes. I have around 150k device processes per node (so up to 500k in total). >>> >>> So, I basically need a global process registry. Not new, but haven't used one in a while now. >>> >>> As far as I can tell, my main options to send messages from one device process to the other based on their id are the erlang global module, ulf's gproc, or implement a custom solution based on, for instance, mnesia in ram only. >>> >>> >>> I was first thinking of leaning towards using the erlang global module, since register_name/2,3 now also allows general terms to be used as Name. The advantages I see: >>> >>> * It is a simple built-in mechanism. >>> * If a node goes down, the global names registered on that node are unregistered automatically. >>> * If a new node is added, the global names registered are propagated automatically. >>> >>> The cons: >>> >>> * I always feel that process registration should be used to identify long-running services. >>> * I don't know if 500k is an acceptable number (i.e. if the global module is made to support my use case). >>> >>> >>> I also looked into gproc. The advantages I see: >>> >>> * Actively maintained, it seems to have been built for my use case. >>> >>> The cons: >>> >>> * For the distributed part it relies on gen_leader. I've heard too many horror stories on gen_leader. Maybe that's not a thing anymore. >>> * Not sure what happens if a node goes down / a new node is added. >>> >>> >>> I've considered a custom solution based on mnesia distributed ram-only tables that would store the pids of the device loops based on their binary id.The advantages I see: >>> >>> * Mnesia will take care of distributing, handling down events, etc. >>> >>> The cons: >>> >>> * I need to reinvent the wheel and ensure that when a node goes down, all the device entries in the distributed mnesia tables related to that node are removed. >>> >>> >>> >>> Has someone recently implemented a distributed process registry and can shed some light for me? >>> >>> Thank you in advance for your advice ^^_ >>> r. >>> >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> You are missing a few options: >> >> http://www.erlang.org/doc/man/pg2.html >> * Any term can be used for a name >> >> https://github.com/okeuday/cpg/ >> * By default uses string (list of integer) names, but can be changed with group_storage application env setting (e.g., to dict) >> * Supports any number of scopes, which are atoms that are used as locally registered cpg process identifiers (pg2 only supports the single global scope stored in ETS) >> * Supports the via syntax, like gproc does, with variations that allow pools to be created (https://github.com/okeuday/cpg/blob/master/test/cpg_test.erl#L83-L104) >> >> Both pg2 and cpg allow you to avoid centralized global state (the state used in gproc, locks_leader, mnesia, global) so that netsplits do not require an arbitrary process to resolve state conflicts. That is very important for reliability. >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto.ostinelli@REDACTED Sun Feb 8 22:22:59 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Sun, 8 Feb 2015 22:22:59 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: Message-ID: <55D756F9-1566-4A6B-9507-9A892AB24E14@widetag.com> Thank you Ulf for this. If I get to use it I'll definitely provide feedback. Best, r. > On 08/feb/2015, at 21:38, Ulf Wiger wrote: > > >> On 08 Feb 2015, at 20:56, Roberto Ostinelli wrote: >> >> For the distributed part it relies on gen_leader. I've heard too many horror stories on gen_leader. Maybe that's not a thing anymore. > > Personally, I?m putting my energy into locks_leader rather than gen_leader. There is a gproc branch that uses locks_leader [1], and I?m willing to support it (OSS-style, that is, best-effort unless someone actually pays me). > > I?d love to make the locks_leader version the main track for distributed gproc, but am hoping for field reports from people actually using locks_leader in anger. > > [1] https://github.com/uwiger/gproc/tree/uw-locks_leader > > BR, > Ulf W > > Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. > http://feuerlabs.com > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From essen@REDACTED Sun Feb 8 22:41:25 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Sun, 08 Feb 2015 22:41:25 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <54D7D0B6.3090901@gmail.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> Message-ID: <54D7D805.2090706@ninenines.eu> On 02/08/2015 10:10 PM, Michael Truog wrote: >> Is there any reason why using these process groups be beneficial in my >> use case? > The main reason is that you avoid the need to resolve state conflicts > when global state gets merged after a netsplit. With pg2 and cpg, all > the state relevant to the local node is stored locally and remote state > gets merged as nodes are added. When a node dies, its pids are removed, > as expected, but there is no need for centralized global state. I'm curious. When a node connects it sends its state to all the nodes it connects to? And when a process group gets registered it sends this info to all the nodes? -- Lo?c Hoguin http://ninenines.eu From roberto.ostinelli@REDACTED Sun Feb 8 23:07:38 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Sun, 8 Feb 2015 23:07:38 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <54D7D0B6.3090901@gmail.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> Message-ID: <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> Hi Michael, Do you know what the impact of this is when you add/remove keys often? I'm imagining a lot of communication (async) happening between nodes. I'm actually very ok with the AP portion of the CAP theorem (that pg2 seems to offer) in contrast with the CA (of global/gproc). Just wandering if there are studies and impact on performance. As said, I have 3 nodes with a total of 500k pids that need registration Thanks, r. > On 08/feb/2015, at 22:10, Michael Truog wrote: > > The main reason is that you avoid the need to resolve state conflicts when global state gets merged after a netsplit. With pg2 and cpg, all the state relevant to the local node is stored locally and remote state gets merged as nodes are added. When a node dies, its pids are removed, as expected, but there is no need for centralized global state. From roberto.ostinelli@REDACTED Sun Feb 8 23:09:58 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Sun, 8 Feb 2015 23:09:58 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> Message-ID: <74E49437-1C6A-4CA5-AD93-4A1015AAF885@widetag.com> > in contrast with the CA (of global/gproc). Sorry I meant CP. From mjtruog@REDACTED Sun Feb 8 23:14:06 2015 From: mjtruog@REDACTED (Michael Truog) Date: Sun, 08 Feb 2015 14:14:06 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <54D7D805.2090706@ninenines.eu> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <54D7D805.2090706@ninenines.eu> Message-ID: <54D7DFAE.3030704@gmail.com> On 02/08/2015 01:41 PM, Lo?c Hoguin wrote: > On 02/08/2015 10:10 PM, Michael Truog wrote: >>> Is there any reason why using these process groups be beneficial in my >>> use case? >> The main reason is that you avoid the need to resolve state conflicts >> when global state gets merged after a netsplit. With pg2 and cpg, all >> the state relevant to the local node is stored locally and remote state >> gets merged as nodes are added. When a node dies, its pids are removed, >> as expected, but there is no need for centralized global state. > > I'm curious. > > When a node connects it sends its state to all the nodes it connects to? And when a process group gets registered it sends this info to all the nodes? > Yes, basically. Node connections are monitored and when a new node appears (after a nodesplit or a new node connection) the cpg scope process sends its state to the new node's cpg scope process. When cpg is first started, it also makes sure to let the other nodes cpg processes know it exists, so they will send their state to it. The state is merged, so that remote pids are stored and monitored. When a cpg process is added to a group, it is added locally, and the addition is sent asynchronously to remote nodes (if they don't receive it, a netsplit or reliability problem is happening anyway, so that will get resolved as described above). This functions like pg2, except that pg2 only uses a single scope and makes the addition synchronous, relying on the global module for a global transaction lock. The cpg approach avoids a global lock by requiring that the cpg scope process be locally consistent (as if the single Erlang process functions as a mutex lock), which means that the cpg process is only dealing with local node pids (you can not add remote pids to the local cpg process). There is a macro to get the pg2 approach in cpg (undefine GROUP_NAME_WITH_LOCAL_PIDS_ONLY), but it is better to use that restriction to avoid a dependency on the global module. The cpg return values are the same as pg2, so you can switch between them if you aren't using cpg specific features, like scopes. cpg doesn't require a group be created before the join, but pg2 does. So cpg usage can rely only upon join/leave for group membership. From mjtruog@REDACTED Sun Feb 8 23:52:01 2015 From: mjtruog@REDACTED (Michael Truog) Date: Sun, 08 Feb 2015 14:52:01 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> Message-ID: <54D7E891.5000000@gmail.com> On 02/08/2015 02:07 PM, Roberto Ostinelli wrote: > Hi Michael, > Do you know what the impact of this is when you add/remove keys often? I'm imagining a lot of communication (async) happening between nodes. > > I'm actually very ok with the AP portion of the CAP theorem (that pg2 seems to offer) in contrast with the CA (of global/gproc). > > Just wandering if there are studies and impact on performance. As said, I have 3 nodes with a total of 500k pids that need registration > > Thanks, > r. I know that pg2 has performance problems due to the global module usage and that cpg avoids that. However, I have not taken the time to test the difference and quantify the benefit, since that depends on how nodes fail and the problem size. So, it is probably best if you do your own testing based on your usage, to get results that are relevant to you. > > > >> On 08/feb/2015, at 22:10, Michael Truog wrote: >> >> The main reason is that you avoid the need to resolve state conflicts when global state gets merged after a netsplit. With pg2 and cpg, all the state relevant to the local node is stored locally and remote state gets merged as nodes are added. When a node dies, its pids are removed, as expected, but there is no need for centralized global state. From radek@REDACTED Sun Feb 8 23:54:37 2015 From: radek@REDACTED (Radoslaw Gruchalski) Date: Sun, 8 Feb 2015 23:54:37 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <54D7DFAE.3030704@gmail.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <54D7D805.2090706@ninenines.eu> <54D7DFAE.3030704@gmail.com> Message-ID: Michael, Out of curiosity, do you have any occasional pings? How do you know when the netsplit happened? You rely on erlang facilities only? Kind regards, Radek Gruchalski radek@REDACTED *Confidentiality:* This communication is intended for the above-named person and may be confidential and/or legally privileged. If it has come to you in error you must take no action based on it, nor must you copy or show it to anyone; please delete/destroy and inform the sender immediately. On Sun, Feb 8, 2015 at 11:14 PM, Michael Truog wrote: > On 02/08/2015 01:41 PM, Lo?c Hoguin wrote: > >> On 02/08/2015 10:10 PM, Michael Truog wrote: >> >>> Is there any reason why using these process groups be beneficial in my >>>> use case? >>>> >>> The main reason is that you avoid the need to resolve state conflicts >>> when global state gets merged after a netsplit. With pg2 and cpg, all >>> the state relevant to the local node is stored locally and remote state >>> gets merged as nodes are added. When a node dies, its pids are removed, >>> as expected, but there is no need for centralized global state. >>> >> >> I'm curious. >> >> When a node connects it sends its state to all the nodes it connects to? >> And when a process group gets registered it sends this info to all the >> nodes? >> >> Yes, basically. Node connections are monitored and when a new node > appears (after a nodesplit or a new node connection) the cpg scope process > sends its state to the new node's cpg scope process. When cpg is first > started, it also makes sure to let the other nodes cpg processes know it > exists, so they will send their state to it. The state is merged, so that > remote pids are stored and monitored. > > When a cpg process is added to a group, it is added locally, and the > addition is sent asynchronously to remote nodes (if they don't receive it, > a netsplit or reliability problem is happening anyway, so that will get > resolved as described above). This functions like pg2, except that pg2 > only uses a single scope and makes the addition synchronous, relying on the > global module for a global transaction lock. The cpg approach avoids a > global lock by requiring that the cpg scope process be locally consistent > (as if the single Erlang process functions as a mutex lock), which means > that the cpg process is only dealing with local node pids (you can not add > remote pids to the local cpg process). There is a macro to get the pg2 > approach in cpg (undefine GROUP_NAME_WITH_LOCAL_PIDS_ONLY), but it is > better to use that restriction to avoid a dependency on the global module. > The cpg return values are the same as pg2, so you can switch between them > if you aren't using cpg specific features, like scopes. > > cpg doesn't require a group be created before the join, but pg2 does. So > cpg usage can rely only upon join/leave for group membership. > > _______________________________________________ > 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 Sun Feb 8 23:57:34 2015 From: mjtruog@REDACTED (Michael Truog) Date: Sun, 08 Feb 2015 14:57:34 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <74E49437-1C6A-4CA5-AD93-4A1015AAF885@widetag.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> <74E49437-1C6A-4CA5-AD93-4A1015AAF885@widetag.com> Message-ID: <54D7E9DE.1040107@gmail.com> On 02/08/2015 02:09 PM, Roberto Ostinelli wrote: >> in contrast with the CA (of global/gproc). > Sorry I meant CP. > Yeah, this is a tricky one. You are attempting to say global/gproc handles partitions, but they don't handle global state in a consistent way after a netsplit (e.g., unsplit with mnesia allows you to arbitrary resolve a different data after a netsplit). Due to this lack of consistency it is incorrect to say global or gproc are partition tolerant. Yes, they can handle a netsplit occurring, but they do not tolerate the failure in a consistent way. The handling is ad-hoc, based on your specific use-case, which might as well be based on random numbers to pick which data is correct, so then that is leading to data loss. The time spent resolving the netsplit causes availability problems, but I believe that is less significant than the partition tolerance short-comings, so I would rather look at them as CA systems, despite the fact others would disagree, since they do try hard to handle a netsplit, without handling the state involved. You can call it CP if it helps you sleep better at night. From ulf@REDACTED Mon Feb 9 00:04:08 2015 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 9 Feb 2015 00:04:08 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> Message-ID: > On 08 Feb 2015, at 23:07, Roberto Ostinelli wrote: > > I'm actually very ok with the AP portion of the CAP theorem (that pg2 seems to offer) in contrast with the CA (of global/gproc). A minor detail: When recovering from netsplits in gproc, only unique names must be resolved so that there is only one (by definition of ?unique?). If you want to implement a global broadcast group, you would do that using ?properties?, and they are simply merged after netsplit - there is no uniqueness constraint. BR, Ulf W Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. http://feuerlabs.com From mjtruog@REDACTED Mon Feb 9 00:07:47 2015 From: mjtruog@REDACTED (Michael Truog) Date: Sun, 08 Feb 2015 15:07:47 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <54D7D805.2090706@ninenines.eu> <54D7DFAE.3030704@gmail.com> Message-ID: <54D7EC43.7080806@gmail.com> On 02/08/2015 02:54 PM, Radoslaw Gruchalski wrote: > Michael, > > Out of curiosity, do you have any occasional pings? How do you know when the netsplit happened? You rely on erlang facilities only? Both cpg and pg2 rely on Erlang node monitoring provided by distributed Erlang. Distributed Erlang is using the node heartbeat configured with net_ticktime (http://erlang.org/doc/man/kernel_app.html). > > Kind regards, > > Radek Gruchalski > radek@REDACTED > > *Confidentiality:* > This communication is intended for the above-named person and may be confidential and/or legally privileged. > If it has come to you in error you must take no action based on it, nor must you copy or show it to anyone; please delete/destroy and inform the sender immediately. > > > On Sun, Feb 8, 2015 at 11:14 PM, Michael Truog > wrote: > > On 02/08/2015 01:41 PM, Lo?c Hoguin wrote: > > On 02/08/2015 10:10 PM, Michael Truog wrote: > > Is there any reason why using these process groups be beneficial in my > use case? > > The main reason is that you avoid the need to resolve state conflicts > when global state gets merged after a netsplit. With pg2 and cpg, all > the state relevant to the local node is stored locally and remote state > gets merged as nodes are added. When a node dies, its pids are removed, > as expected, but there is no need for centralized global state. > > > I'm curious. > > When a node connects it sends its state to all the nodes it connects to? And when a process group gets registered it sends this info to all the nodes? > > Yes, basically. Node connections are monitored and when a new node appears (after a nodesplit or a new node connection) the cpg scope process sends its state to the new node's cpg scope process. When cpg is first started, it also makes sure to let the other nodes cpg processes know it exists, so they will send their state to it. The state is merged, so that remote pids are stored and monitored. > > When a cpg process is added to a group, it is added locally, and the addition is sent asynchronously to remote nodes (if they don't receive it, a netsplit or reliability problem is happening anyway, so that will get resolved as described above). This functions like pg2, except that pg2 only uses a single scope and makes the addition synchronous, relying on the global module for a global transaction lock. The cpg approach avoids a global lock by requiring that the cpg scope process be locally consistent (as if the single Erlang process functions as a mutex lock), which means that the cpg process is only dealing with local node pids (you can not add remote pids to the local cpg process). There is a macro to get the pg2 approach in cpg (undefine GROUP_NAME_WITH_LOCAL_PIDS_ONLY), but it is better to use that restriction to avoid a dependency on the global module. The cpg return values are the same as pg2, so you can switch between them if you aren't using cpg specific > features, like scopes. > > cpg doesn't require a group be created before the join, but pg2 does. So cpg usage can rely only upon join/leave for group membership. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Mon Feb 9 00:27:47 2015 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 9 Feb 2015 00:27:47 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <54D7E9DE.1040107@gmail.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> <74E49437-1C6A-4CA5-AD93-4A1015AAF885@widetag.com> <54D7E9DE.1040107@gmail.com> Message-ID: > On 08 Feb 2015, at 23:57, Michael Truog wrote: > > Due to this lack of consistency it is incorrect to say global or gproc are partition tolerant. Yes, they can handle a netsplit occurring, but they do not tolerate the failure in a consistent way. This is an interesting definition of ?tolerant?. So you?re saying that because global and gproc offer a choice of methods to handle a netsplit, they are _less_ tolerant than if they had only one method? Perhaps I misunderstood. I agree that it can be a problem in a given system that different components automatically try to resolve an inconsistency using potentially different strategies. For this reason, I?ve long argued that one should have one master arbiter; the other systems need to be able to adapt. Otherwise, the different conflict resolution decisions can actually _cause_ inconsistencies from a system perspective. I should note that gproc really only does ordered conflict resolution in the uw-locks_leader branch (and I just spotted a bug in it). But again, I don?t think one should compare distributed group membership solutions with gproc?s unique names. They are not the same, just as comparing a transaction-based DBMS with an dynamo-style KV-store is an apples-to-oranges comparison. If you really need to keep one unique instance of something in a distributed system, you will have a consistency challenge whether you want it or not. There will be tradeoffs, and as far as I know, there is no single tradeoff that is the best option for every situation. Thus, different options for different use cases. But properties in gproc are not unique. In the local case, you don?t even need to involve the central gproc server when registering a property (except to ensure monitoring). When merging data after a netsplit, the node when a process resides is considered the authority on what properties exist for the process. This is safe, since only the process itself can register properties. Thus, a process group will be all processes that share a given property. There is no tricky conflict resolution after netsplit in that case. BR, Ulf W Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. http://feuerlabs.com From martink@REDACTED Mon Feb 9 00:31:20 2015 From: martink@REDACTED (Martin Karlsson) Date: Mon, 9 Feb 2015 12:31:20 +1300 Subject: [erlang-questions] Retrieve public key from DER encoded certificate In-Reply-To: References: Message-ID: Hi Eric, > How should I retrieve rsa_public_key() | dsa_public_key() from a DER encoded > certificate? You should look into public_key:der_decode/2 To get a SubjectPublicKeyInfo to rsa_public_key() you need to do something like this: {0, Res} = Info#'SubjectPublicKeyInfo'.subjectPublicKey, public_key:der_decode('RSAPublicKey', Res). We do something similar but do not work with certificates. Hope this helps, Cheers, Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From mjtruog@REDACTED Mon Feb 9 00:51:10 2015 From: mjtruog@REDACTED (Michael Truog) Date: Sun, 08 Feb 2015 15:51:10 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> <74E49437-1C6A-4CA5-AD93-4A1015AAF885@widetag.com> <54D7E9DE.1040107@gmail.com> Message-ID: <54D7F66E.9080705@gmail.com> On 02/08/2015 03:27 PM, Ulf Wiger wrote: >> On 08 Feb 2015, at 23:57, Michael Truog wrote: >> >> Due to this lack of consistency it is incorrect to say global or gproc are partition tolerant. Yes, they can handle a netsplit occurring, but they do not tolerate the failure in a consistent way. > This is an interesting definition of ?tolerant?. So you?re saying that because global and gproc offer a choice of methods to handle a netsplit, they are _less_ tolerant than if they had only one method? Perhaps I misunderstood. If resolving the separate chunks of data that exist after a netsplit requires user source code, to pick which data is "correct", that can not be consistent and is an arbitrary process (ad-hoc, based on your use-case). I don't believe that is being partition tolerant, but is instead ignoring the problem of partition tolerance and telling the user: "you should really figure this out". > > I agree that it can be a problem in a given system that different components automatically try to resolve an inconsistency using potentially different strategies. For this reason, I?ve long argued that one should have one master arbiter; the other systems need to be able to adapt. Otherwise, the different conflict resolution decisions can actually _cause_ inconsistencies from a system perspective. This stance appears to be contradicted by usage of gproc properties. You can have automatic conflict resolution that does not cause inconsistencies, i.e., it does not need to be a manual process that requires a master arbiter. > > I should note that gproc really only does ordered conflict resolution in the uw-locks_leader branch (and I just spotted a bug in it). > > But again, I don?t think one should compare distributed group membership solutions with gproc?s unique names. They are not the same, just as comparing a transaction-based DBMS with an dynamo-style KV-store is an apples-to-oranges comparison. > > If you really need to keep one unique instance of something in a distributed system, you will have a consistency challenge whether you want it or not. There will be tradeoffs, and as far as I know, there is no single tradeoff that is the best option for every situation. Thus, different options for different use cases. Yes. > > But properties in gproc are not unique. In the local case, you don?t even need to involve the central gproc server when registering a property (except to ensure monitoring). When merging data after a netsplit, the node when a process resides is considered the authority on what properties exist for the process. This is safe, since only the process itself can register properties. > > Thus, a process group will be all processes that share a given property. There is no tricky conflict resolution after netsplit in that case. Then that appears to be similar to cpg usage, since cpg is using the node where the process resides as the authority on which groups it is a member of. The gproc unique names are what require manual intervention for obvious reasons, since they are unable to tolerate a partition in a consistent way. I understand this difference is based on use-cases, but I think it is an important distinction. > > BR, > Ulf W > > Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. > http://feuerlabs.com > > > > From max.lapshin@REDACTED Mon Feb 9 05:05:26 2015 From: max.lapshin@REDACTED (Max Lapshin) Date: Mon, 9 Feb 2015 08:05:26 +0400 Subject: [erlang-questions] memsup bug? In-Reply-To: References: Message-ID: Well, it is rather simple: 06:40:23.032 <0.136.0> OS_MON (memsup) timeout, no data collected 06:40:23.033 <0.136.0> gen_server memsup terminated with reason: bad argument in call to erlang:cancel_timer(undefined) in memsup:handle_info/2 line 357 * Last msg: {collected_sys,{2947452928,6115938304}} * State: [{data,[{"Timeout",60000000}]},{items,{"Memory Usage",[{"Allocated",2980851712},{"Total",6229397504}]}},{items,{"Worst Memory User",[{"Pid",<0.309.0>},{"Memory",1803752}]}}] but there are many places where wd_timer is set to undefined, so it is not even checked. I could reproduce it by just closing laptop and opening it back. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Mon Feb 9 08:16:13 2015 From: ulf@REDACTED (Ulf Wiger) Date: Mon, 9 Feb 2015 08:16:13 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: <54D7F66E.9080705@gmail.com> References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> <74E49437-1C6A-4CA5-AD93-4A1015AAF885@widetag.com> <54D7E9DE.1040107@gmail.com> <54D7F66E.9080705@gmail.com> Message-ID: > On 09 Feb 2015, at 00:51, Michael Truog wrote: > > If resolving the separate chunks of data that exist after a netsplit requires user source code, to pick which data is "correct", that can not be consistent and is an arbitrary process (ad-hoc, based on your use-case). I don't believe that is being partition tolerant, but is instead ignoring the problem of partition tolerance and telling the user: "you should really figure this out?. But it?s a pathological problem! (see e.g. the Byzantine Generals dilemma). There is no generic way to resolve a netsplit that will lead to a *functionally consistent* system in every case. That is, data consistency in itself is not the end goal, but rather that conflicts are resolved in a way that the system functions as well as possible afterwards. But saying that a library is inconsistent and arbitrary just because it requires user-level logic is not very helpful. By this reasoning, lists:foldl/3 is arbitrary, since it doesn?t understand how to fold a list in a way that?s ?right? for the user every time. If you accept that user intervention is _required_, at least some of the time (see e.g. lists:sort/1 vs lists:sort/2), you need to provide users with the hooks needed to do the job. >> I agree that it can be a problem in a given system that different components automatically try to resolve an inconsistency using potentially different strategies. For this reason, I?ve long argued that one should have one master arbiter; the other systems need to be able to adapt. Otherwise, the different conflict resolution decisions can actually _cause_ inconsistencies from a system perspective. > This stance appears to be contradicted by usage of gproc properties. You can have automatic conflict resolution that does not cause inconsistencies, i.e., it does not need to be a manual process that requires a master arbiter. What I was referring to here was that different parts of a system can end up ?locally consistent?, but in ways that are not consistent at the system level. For example, if you have a master/slave system where several components independently elect a master, the system will be inconsistent if they end up electing different nodes, _and you expected them to end up with the same master_. Note that whatever is considered wrong is completely a local issue: it might be undesireable if they actually _did_ elect the same master. Either way, if their respective decisions should not be regarded as independent, it is arguably better to have an arbiter decide and tell whoever needs to know. In a very early version of the AXD 301 cluster controller, I used global to elect a leader instance. When the nodes reconnected after netsplit, the cluster controller would immediately start trying to heal the system, but so did global. At that time, global had only one conflict resolution method: it would randomly pick one of the processes and kill it! It was annoying to say the least, for the cluster controller to try to heal the system while global was gunning for it! In this case, we decided that it would be better for global to simply unregister the name - the cluster controller would then automatically elect a new master. The work on the AXD 301 cluster controller resulted in several additions to OTP and decisions on how to handle this sort of thing. For one, 'net_kernel dist_auto_connect once? was introduced to allow the application logic to decide _when_ to reconnect two nodes. Other additions was configurable deconflict methods in global, and the decision to let the user decide how to handle inconsistencies in mnesia. Basically, we needed to be able to _impose_ our view of conflict resolution on OTP, and we were pretty sure that the AXD 301 way of resolving netsplits was not a universal method. But it does not make sense to call it ?arbitrary? (even though a perspective, and an interpretation of the word, can be chosen, to make it a valid claim). The system was architected to handle netsplits in a consistent and robust way. Yes, there are solutions that automatically avoid inconsistencies. One of the design decisions in gproc was to only allow processes to register their own names/properties. This is rather a matter of _conflict avoidance_. Registering a property doesn?t impose any restriction on other processes, like unique name registration does. BR, Ulf W Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. http://feuerlabs.com From mjtruog@REDACTED Mon Feb 9 09:46:11 2015 From: mjtruog@REDACTED (Michael Truog) Date: Mon, 09 Feb 2015 00:46:11 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> <74E49437-1C6A-4CA5-AD93-4A1015AAF885@widetag.com> <54D7E9DE.1040107@gmail.com> <54D7F66E.9080705@gmail.com> Message-ID: <54D873D3.4090902@gmail.com> On 02/08/2015 11:16 PM, Ulf Wiger wrote: >> On 09 Feb 2015, at 00:51, Michael Truog wrote: >> >> If resolving the separate chunks of data that exist after a netsplit requires user source code, to pick which data is "correct", that can not be consistent and is an arbitrary process (ad-hoc, based on your use-case). I don't believe that is being partition tolerant, but is instead ignoring the problem of partition tolerance and telling the user: "you should really figure this out?. > But it?s a pathological problem! (see e.g. the Byzantine Generals dilemma). There is no generic way to resolve a netsplit that will lead to a *functionally consistent* system in every case. That is, data consistency in itself is not the end goal, but rather that conflicts are resolved in a way that the system functions as well as possible afterwards. I agree that using a master/slave relationship to store data creates a difficult problem. Many solutions have been discussed and you have implemented an approach in gproc. I agree that you are focused on being able to resolve conflicts manually, because that is the only option. However, the CAP theorem does have a C for consistency. If your system fails data consistency, due to being unable to handle partition tolerance without sacrificing consistency (possibly with a loss of data), that should impact the view of the system as it relates to the CAP theorem. I don't think it is realistic to say gproc is able to handle A out of CAP, since that doesn't really show its focus (for unique names, its original focus). It should be better to say gproc is CA since it is not handling partition tolerance issues, the user is with its own source code (i.e., an approach that makes the user's system continue to function in a way that is agreeable, if the user doesn't make a mistake, and it is possible) to resolve conflicts. > > But saying that a library is inconsistent and arbitrary just because it requires user-level logic is not very helpful. By this reasoning, lists:foldl/3 is arbitrary, since it doesn?t understand how to fold a list in a way that?s ?right? for the user every time. If you accept that user intervention is _required_, at least some of the time (see e.g. lists:sort/1 vs lists:sort/2), you need to provide users with the hooks needed to do the job. The comparison to the lists module is invalid, since this relates to distributed computing and the difference between a master/slave system (gproc, specifically unique names) and a master-less system (cpg). The usage of gproc unique names requires the user to resolve state conflicts manually after a netsplit, and that makes the process arbitrary since it is undefined within gproc. The user can do anything which includes incorrect source code and choosing to ignore the problem. The potential for problems impacts the reliability expected when a netsplit occurs. Having netsplits resolved without user source code in cpg avoids the possibility of reliability suffering after a netsplit, since common source code is used which is testable, it is not undefined user source code. > > >>> I agree that it can be a problem in a given system that different components automatically try to resolve an inconsistency using potentially different strategies. For this reason, I?ve long argued that one should have one master arbiter; the other systems need to be able to adapt. Otherwise, the different conflict resolution decisions can actually _cause_ inconsistencies from a system perspective. >> This stance appears to be contradicted by usage of gproc properties. You can have automatic conflict resolution that does not cause inconsistencies, i.e., it does not need to be a manual process that requires a master arbiter. > What I was referring to here was that different parts of a system can end up ?locally consistent?, but in ways that are not consistent at the system level. For example, if you have a master/slave system where several components independently elect a master, the system will be inconsistent if they end up electing different nodes, _and you expected them to end up with the same master_. Note that whatever is considered wrong is completely a local issue: it might be undesireable if they actually _did_ elect the same master. Either way, if their respective decisions should not be regarded as independent, it is arguably better to have an arbiter decide and tell whoever needs to know. > > In a very early version of the AXD 301 cluster controller, I used global to elect a leader instance. When the nodes reconnected after netsplit, the cluster controller would immediately start trying to heal the system, but so did global. At that time, global had only one conflict resolution method: it would randomly pick one of the processes and kill it! It was annoying to say the least, for the cluster controller to try to heal the system while global was gunning for it! In this case, we decided that it would be better for global to simply unregister the name - the cluster controller would then automatically elect a new master. > > The work on the AXD 301 cluster controller resulted in several additions to OTP and decisions on how to handle this sort of thing. For one, 'net_kernel dist_auto_connect once? was introduced to allow the application logic to decide _when_ to reconnect two nodes. Other additions was configurable deconflict methods in global, and the decision to let the user decide how to handle inconsistencies in mnesia. Basically, we needed to be able to _impose_ our view of conflict resolution on OTP, and we were pretty sure that the AXD 301 way of resolving netsplits was not a universal method. But it does not make sense to call it ?arbitrary? (even though a perspective, and an interpretation of the word, can be chosen, to make it a valid claim). The system was architected to handle netsplits in a consistent and robust way. The system does handle netsplits in a deterministic way, until the user needs to make the decisions about what data to discard. The decision the user makes can be seen as arbitrary when looking at the system, since it is undefined within the system. Users can make the decision deterministic based on their use-case, but that doesn't avoid the potential for data loss or the latency during the decision process (in their custom source code). > > Yes, there are solutions that automatically avoid inconsistencies. One of the design decisions in gproc was to only allow processes to register their own names/properties. This is rather a matter of _conflict avoidance_. Registering a property doesn?t impose any restriction on other processes, like unique name registration does. I understand that registering a local property in gproc does not need to be unique and have failures like unique names do within gproc. However, it doesn't appear that local properties are accessible through gproc in useful ways that make it comparable with cpg for process groups (or comparable to pg2). I just don't see how local properties can be useful as they are provided by gproc when compared to basic ets usage or locally registered names for Erlang processes. So, I can agree that local properties can avoid conflicts in gproc, since they are local, but so what? Doesn't using gproc only for local properties just impose unnecessary complexity? > > BR, > Ulf W > > Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. > http://feuerlabs.com > > > > From puzza007@REDACTED Mon Feb 9 10:32:12 2015 From: puzza007@REDACTED (Paul Oliver) Date: Mon, 09 Feb 2015 09:32:12 +0000 Subject: [erlang-questions] Distributed Process Registry References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> Message-ID: Hi Roberto, In my experience cpg struggles with a high volume of joins/leaves. By default it uses a single gen_server as part of all such calls (the default scope) and in my production system this ended up being a bottleneck. A potential workaround might be to create a bunch of scopes and hash over them. Cheers, Paul. On Sun Feb 08 2015 at 11:07:52 PM Roberto Ostinelli < roberto.ostinelli@REDACTED> wrote: > Hi Michael, > Do you know what the impact of this is when you add/remove keys often? I'm > imagining a lot of communication (async) happening between nodes. > > I'm actually very ok with the AP portion of the CAP theorem (that pg2 > seems to offer) in contrast with the CA (of global/gproc). > > Just wandering if there are studies and impact on performance. As said, I > have 3 nodes with a total of 500k pids that need registration > > Thanks, > r. > > > > > On 08/feb/2015, at 22:10, Michael Truog wrote: > > > > The main reason is that you avoid the need to resolve state conflicts > when global state gets merged after a netsplit. With pg2 and cpg, all the > state relevant to the local node is stored locally and remote state gets > merged as nodes are added. When a node dies, its pids are removed, as > expected, but there is no need for centralized global state. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben@REDACTED Mon Feb 9 10:38:48 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Mon, 09 Feb 2015 10:38:48 +0100 Subject: [erlang-questions] is this a well written function Message-ID: <54D88028.8000802@home.nl> Hello, I tried to solve the exercise where I have to calculate the outcome of 1 ... n So I have this : -module(sum_recursion). -export([sum/1]). % when the number is zero the outcome will also be zero sum(0) -> 0; % when the output is a number higher then 0 , the acc function will be called. sum(Number) -> sum_acc(Number, 0, 0 ). % when the numbers are equal then the end is reached and the last item is added to the acc variable, % the acc variable hold the value of the sum as it is calculated sum_acc(Endnumber, Endnumber, Acc) -> Acc + Endnumber ; % when the numbers are not equal then the end is not reached so the function is again called with the original number, % the loop is increased by 1 and the acc function hold the value of the sum as it is calculated. sum_acc(Endnumber, Number, Acc) -> sum_acc(Endnumber, Number + 1, Acc + Number). Now I wonder if this is well written Erlang ? Roelof From bengt.kleberg@REDACTED Mon Feb 9 10:46:41 2015 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Mon, 9 Feb 2015 10:46:41 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: <54D88028.8000802@home.nl> References: <54D88028.8000802@home.nl> Message-ID: <54D88201.804@ericsson.com> I like it. It could be enhanced with a test that _input_ Number is higher _than_ 0 in: % when the output is a number higher then 0 , the acc function will be called. sum(Number) -> sum_acc(Number, 0, 0 ). bengt On 02/09/2015 10:38 AM, Roelof Wobben wrote: > Hello, > > I tried to solve the exercise where I have to calculate the outcome of > 1 ... n > > So I have this : > > -module(sum_recursion). > > -export([sum/1]). > > % when the number is zero the outcome will also be zero > sum(0) -> > 0; > > % when the output is a number higher then 0 , the acc function will be > called. > sum(Number) -> sum_acc(Number, 0, 0 ). > > % when the numbers are equal then the end is reached and the last item > is added to the acc variable, > % the acc variable hold the value of the sum as it is calculated > sum_acc(Endnumber, Endnumber, Acc) -> > Acc + Endnumber ; > > % when the numbers are not equal then the end is not reached so the > function is again called with the original number, > % the loop is increased by 1 and the acc function hold the value of > the sum as it is calculated. > sum_acc(Endnumber, Number, Acc) -> > sum_acc(Endnumber, Number + 1, Acc + Number). > > > Now I wonder if this is well written Erlang ? > > Roelof > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From masklinn@REDACTED Mon Feb 9 10:51:19 2015 From: masklinn@REDACTED (Masklinn) Date: Mon, 9 Feb 2015 10:51:19 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: <54D88028.8000802@home.nl> References: <54D88028.8000802@home.nl> Message-ID: <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> On 2015-02-09, at 10:38 , Roelof Wobben wrote: > Hello, > > I tried to solve the exercise where I have to calculate the outcome of 1 ... n > > So I have this : > > -module(sum_recursion). > > -export([sum/1]). > > % when the number is zero the outcome will also be zero > sum(0) -> > 0; > > % when the output is a number higher then 0 , the acc function will be called. > sum(Number) -> sum_acc(Number, 0, 0 ). > > % when the numbers are equal then the end is reached and the last item is added to the acc variable, > % the acc variable hold the value of the sum as it is calculated > sum_acc(Endnumber, Endnumber, Acc) -> > Acc + Endnumber ; > > % when the numbers are not equal then the end is not reached so the function is again called with the original number, > % the loop is increased by 1 and the acc function hold the value of the sum as it is calculated. > sum_acc(Endnumber, Number, Acc) -> > sum_acc(Endnumber, Number + 1, Acc + Number). > > > Now I wonder if this is well written Erlang ? I'd tend to write something like this instead: sum(End) -> sum_acc(0, 0, End). sum_acc(Acc, _, 0) -> Acc; sum_acc(Acc, Current, Rem) -> sum_acc(Acc + Current, Current + 1, Rem - 1). From davidnwelton@REDACTED Mon Feb 9 10:58:34 2015 From: davidnwelton@REDACTED (David Welton) Date: Mon, 9 Feb 2015 10:58:34 +0100 Subject: [erlang-questions] net_kernel:start oddity In-Reply-To: References: Message-ID: Ok, here's a big part of the problem: the local network is not put together very well, so 'kiger.buildd' is not resolving. That would certainly cause problems. It still seems like a bit of a mystery why one would work and the other would not, though. And the lack of meaningful error messages does not help either. -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From sergej.jurecko@REDACTED Mon Feb 9 11:00:49 2015 From: sergej.jurecko@REDACTED (=?UTF-8?Q?Sergej_Jure=C4=8Dko?=) Date: Mon, 9 Feb 2015 11:00:49 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> Message-ID: Now that we see how deep this rabbit hole goes. Would it perhaps be feasible to only use a local registry on each node, then send every message to both nodes. If a node does not have a process you're looking for registered it just returns error or does nothing. Sergej On Mon, Feb 9, 2015 at 10:32 AM, Paul Oliver wrote: > Hi Roberto, > > In my experience cpg struggles with a high volume of joins/leaves. By > default it uses a single gen_server as part of all such calls (the default > scope) and in my production system this ended up being a bottleneck. A > potential workaround might be to create a bunch of scopes and hash over > them. > > Cheers, > Paul. > > > On Sun Feb 08 2015 at 11:07:52 PM Roberto Ostinelli < > roberto.ostinelli@REDACTED> wrote: > >> Hi Michael, >> Do you know what the impact of this is when you add/remove keys often? >> I'm imagining a lot of communication (async) happening between nodes. >> >> I'm actually very ok with the AP portion of the CAP theorem (that pg2 >> seems to offer) in contrast with the CA (of global/gproc). >> >> Just wandering if there are studies and impact on performance. As said, I >> have 3 nodes with a total of 500k pids that need registration >> >> Thanks, >> r. >> >> >> >> > On 08/feb/2015, at 22:10, Michael Truog wrote: >> > >> > The main reason is that you avoid the need to resolve state conflicts >> when global state gets merged after a netsplit. With pg2 and cpg, all the >> state relevant to the local node is stored locally and remote state gets >> merged as nodes are added. When a node dies, its pids are removed, as >> expected, but there is no need for centralized global state. >> _______________________________________________ >> 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 mjtruog@REDACTED Mon Feb 9 11:09:21 2015 From: mjtruog@REDACTED (Michael Truog) Date: Mon, 09 Feb 2015 02:09:21 -0800 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> Message-ID: <54D88751.9040402@gmail.com> On 02/09/2015 01:32 AM, Paul Oliver wrote: > Hi Roberto, > > In my experience cpg struggles with a high volume of joins/leaves. By default it uses a single gen_server as part of all such calls (the default scope) and in my production system this ended up being a bottleneck. A potential workaround might be to create a bunch of scopes and hash over them. Yes, using more than the single cpg scope would utilize more than the single Erlang process to avoid it becoming a bottleneck. It also helps to use cached cpg data for the process lookups to avoid adding extra load to the cpg scope Erlang process by using the cpg_data module (after receiving the cpg data with cpg_data:get_groups/2 function) which is equivalent to what happens for a lazy destination refresh in CloudI when sending a service request. > > Cheers, > Paul. > > On Sun Feb 08 2015 at 11:07:52 PM Roberto Ostinelli > wrote: > > Hi Michael, > Do you know what the impact of this is when you add/remove keys often? I'm imagining a lot of communication (async) happening between nodes. > > I'm actually very ok with the AP portion of the CAP theorem (that pg2 seems to offer) in contrast with the CA (of global/gproc). > > Just wandering if there are studies and impact on performance. As said, I have 3 nodes with a total of 500k pids that need registration > > Thanks, > r. > > > > > On 08/feb/2015, at 22:10, Michael Truog > wrote: > > > > The main reason is that you avoid the need to resolve state conflicts when global state gets merged after a netsplit. With pg2 and cpg, all the state relevant to the local node is stored locally and remote state gets merged as nodes are added. When a node dies, its pids are removed, as expected, but there is no need for centralized global state. > _______________________________________________ > 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 r.wobben@REDACTED Mon Feb 9 14:39:46 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Mon, 09 Feb 2015 14:39:46 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> References: <54D88028.8000802@home.nl> <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> Message-ID: <54D8B8A2.5070201@home.nl> Masklinn schreef op 9-2-2015 om 10:51: > On 2015-02-09, at 10:38 , Roelof Wobben wrote: > >> Hello, >> >> I tried to solve the exercise where I have to calculate the outcome of 1 ... n >> >> So I have this : >> >> -module(sum_recursion). >> >> -export([sum/1]). >> >> % when the number is zero the outcome will also be zero >> sum(0) -> >> 0; >> >> % when the output is a number higher then 0 , the acc function will be called. >> sum(Number) -> sum_acc(Number, 0, 0 ). >> >> % when the numbers are equal then the end is reached and the last item is added to the acc variable, >> % the acc variable hold the value of the sum as it is calculated >> sum_acc(Endnumber, Endnumber, Acc) -> >> Acc + Endnumber ; >> >> % when the numbers are not equal then the end is not reached so the function is again called with the original number, >> % the loop is increased by 1 and the acc function hold the value of the sum as it is calculated. >> sum_acc(Endnumber, Number, Acc) -> >> sum_acc(Endnumber, Number + 1, Acc + Number). >> >> >> Now I wonder if this is well written Erlang ? > I'd tend to write something like this instead: > > sum(End) -> sum_acc(0, 0, End). > > sum_acc(Acc, _, 0) -> > Acc; > sum_acc(Acc, Current, Rem) -> > sum_acc(Acc + Current, Current + 1, Rem - 1). > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > Thanks both, This is a version with a guard to take care that n is greater then 0 Masklinn, I will study your version to see how you see when it's is the end. Roelof From r.wobben@REDACTED Mon Feb 9 15:11:20 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Mon, 09 Feb 2015 15:11:20 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: <54D8B8A2.5070201@home.nl> References: <54D88028.8000802@home.nl> <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> <54D8B8A2.5070201@home.nl> Message-ID: <54D8C008.2080006@home.nl> Roelof Wobben schreef op 9-2-2015 om 14:39: > sum(End) -> sum_acc(0, 0, End). > > sum_acc(Acc, _, 0) -> > Acc; > sum_acc(Acc, Current, Rem) -> > sum_acc(Acc + Current, Current + 1, Rem - 1). A new try after some remarks : -module(sum_recursion). -export([sum/1]). % when the number is zero the outcome will also be zero sum(0) -> 0; % when a number is greater then 0 , call the helper function. sum(End) when End > 0 -> sum_acc(0, End). % When End is equal to zero all the numbers are added sum_acc(Acc, 0) -> Acc; % when end is not zero there are more numbers to be added. sum_acc(Acc, End) -> sum_acc(Acc + End, End - 1). Roelof From mrtndimitrov@REDACTED Mon Feb 9 15:32:22 2015 From: mrtndimitrov@REDACTED (Martin Koroudjiev) Date: Mon, 09 Feb 2015 16:32:22 +0200 Subject: [erlang-questions] is this a well written function In-Reply-To: <54D8C008.2080006@home.nl> References: <54D88028.8000802@home.nl> <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> <54D8B8A2.5070201@home.nl> <54D8C008.2080006@home.nl> Message-ID: <54D8C4F6.90201@gmail.com> It's perfect, just note that you will get "no function clause" exception if you pass negative number to the function which is probably desired result. Martin On 2/9/2015 4:11 PM, Roelof Wobben wrote: > Roelof Wobben schreef op 9-2-2015 om 14:39: >> sum(End) -> sum_acc(0, 0, End). >> >> sum_acc(Acc, _, 0) -> >> Acc; >> sum_acc(Acc, Current, Rem) -> >> sum_acc(Acc + Current, Current + 1, Rem - 1). > > > A new try after some remarks : > > -module(sum_recursion). > > -export([sum/1]). > > % when the number is zero the outcome will also be zero > sum(0) -> > 0; > > % when a number is greater then 0 , call the helper function. > sum(End) when End > 0 -> > sum_acc(0, End). > > % When End is equal to zero all the numbers are added > sum_acc(Acc, 0) -> > Acc; > > % when end is not zero there are more numbers to be added. > sum_acc(Acc, End) -> > sum_acc(Acc + End, End - 1). > > Roelof > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From r.wobben@REDACTED Mon Feb 9 15:38:10 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Mon, 09 Feb 2015 15:38:10 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: <54D8C4F6.90201@gmail.com> References: <54D88028.8000802@home.nl> <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> <54D8B8A2.5070201@home.nl> <54D8C008.2080006@home.nl> <54D8C4F6.90201@gmail.com> Message-ID: <54D8C652.2060201@home.nl> I know , the exercise is stated this : Write a function sum/1which, given a positive integer N, will return the sum of all the integers between 1 and N. Roelof Martin Koroudjiev schreef op 9-2-2015 om 15:32: > It's perfect, just note that you will get "no function clause" exception > if you pass negative number to the function which is probably desired > result. > > Martin > > On 2/9/2015 4:11 PM, Roelof Wobben wrote: >> Roelof Wobben schreef op 9-2-2015 om 14:39: >>> sum(End) -> sum_acc(0, 0, End). >>> >>> sum_acc(Acc, _, 0) -> >>> Acc; >>> sum_acc(Acc, Current, Rem) -> >>> sum_acc(Acc + Current, Current + 1, Rem - 1). >> >> A new try after some remarks : >> >> -module(sum_recursion). >> >> -export([sum/1]). >> >> % when the number is zero the outcome will also be zero >> sum(0) -> >> 0; >> >> % when a number is greater then 0 , call the helper function. >> sum(End) when End > 0 -> >> sum_acc(0, End). >> >> % When End is equal to zero all the numbers are added >> sum_acc(Acc, 0) -> >> Acc; >> >> % when end is not zero there are more numbers to be added. >> sum_acc(Acc, End) -> >> sum_acc(Acc + End, End - 1). >> >> Roelof >> _______________________________________________ >> 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 sean@REDACTED Mon Feb 9 15:40:52 2015 From: sean@REDACTED (Sean Cribbs) Date: Mon, 9 Feb 2015 08:40:52 -0600 Subject: [erlang-questions] [ANN] PaPoC Workshop Deadline Extended to Feb 17 Message-ID: *Workshop on Principles and Practice of Consistency for Distributed Data (PaPoC)* @ Eurosys 2015 April 21, 2015. Bordeaux, France http://papoc.di.uminho.pt Many distributed applications today need low-latency, scalability, high availability, and geo-replication. The well-known tradeoff between Consistency, Availability, and Partition Tolerance (and low latency) led to the development of weakly consistent data stores, whose success made clear that ?one size does not fit all? when it comes to consistency. Designing correct applications using weakly consistent shared data, however, is a challenging task. The PaPoC workshop will bring forth ideas on how to use, specify, and implement consistency semantics ranging from weaker to stronger models. It will bring together academic researchers, industrial researchers, and practitioners coming from different fields: distributed algorithms, distributed systems, databases, programming languages, and verification. Each of these fields has attacked the problem of consistency from a different angle and there is ample opportunity for synergies. PaPoC is the direct successor of the EuroSys 2014 Workshop on Principles and Practice of Eventual Consistency, which was attended by approximately 40 researchers from the above fields. Submissions should be short papers (2 pages or more) on cutting-edge work, even if ongoing, or vision papers. Accepted papers will be published in ACM Digital Library only upon the request of the authors. Examples of relevant discussion topics include: ? Design principles, correctness conditions, and programming patterns for scalable distributed data systems. ? Techniques for weak consistency: session guarantees, causal consistency, operational transformation, conflict-free replicated data types, monotonic programming, state merge, commutativity, etc. ? Consistency vs. performance and scalability trade-offs: guiding developers, controlling the system. ? Analysis and verification of weakly consistent programs. ? Strengthening guarantees of weakly consistent system: transactions, fault tolerance, security, ensuring invariants, bounding metadata size, and controlling divergence. ? Platform guarantees vs. application involvement: guiding developers, controlling the system. More information about the conference can be found in the conference website http://papoc.di.uminho.pt *IMPORTANT DATES* *Paper submission (NEW):* February 17, 2015 *Notifications:* March 6, 2015 *Workshop: *April 21, 2015 (in Bordeaux, France - colocated with Eurosys 2015) *ORGANIZATION* *Program Chairs* ? Carlos Baquero (INESC TEC & University of Minho, Portugal) ? Marco Serafini (Qatar Computing Research Institute, Qatar) *Program Committee* ? Peter Alvaro (UC Berkeley, USA) ? Sebastian Burckhardt (Microsoft Research, USA) ? Sean Cribbs (Basho Technologies Inc., USA) ? Wojciech Golab (University of Waterloo, Canada) ? Rachid Guerraoui (?cole Polytechnique F?d?rale de Lausanne, Switzerland) ? Lindsey Kuper (Intel Labs, USA) ? Rune Skou Larsen (Trifork, Denmark) ? Fernando Pedone (University of Lugano (USI), Switzerland) ? Rodrigo Rodrigues (NOVA-LINCS & NOVA University of Lisbon, Portugal) ? Kapil Vaswani (Microsoft Research, India) *Steering Committee* ? Peter Bailis (UC Berkeley, USA) ? Alexey Gotsman (IMDEA Software, Spain) ? Nuno Preguic?a (NOVA-LINCS & NOVA University of Lisbon, Portugal) ? Marc Shapiro (INRIA & LIP6, France) ? Justin Sheehy (VMware Inc., USA) -- Sean Cribbs Sr. Software Engineer Basho Technologies, Inc. http://basho.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From mononcqc@REDACTED Mon Feb 9 16:18:11 2015 From: mononcqc@REDACTED (Fred Hebert) Date: Mon, 9 Feb 2015 10:18:11 -0500 Subject: [erlang-questions] is this a well written function In-Reply-To: <54D8C008.2080006@home.nl> References: <54D88028.8000802@home.nl> <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> <54D8B8A2.5070201@home.nl> <54D8C008.2080006@home.nl> Message-ID: <20150209151810.GJ90397@ferdair.local> On 02/09, Roelof Wobben wrote: > A new try after some remarks : > > % When End is equal to zero all the numbers are added > sum_acc(Acc, 0) -> > Acc; The only criticism I'd have is that usually, Erlang programmers will put the accumulator last in the list of arguments, and the variable you iterate on in first positions. So the function clause above would be sum_acc(0, Acc) -> Acc; Regards, Fred. From bob@REDACTED Mon Feb 9 16:22:35 2015 From: bob@REDACTED (Robert Wilkinson) Date: Mon, 9 Feb 2015 16:22:35 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: <54D8C652.2060201@home.nl> References: <54D88028.8000802@home.nl> <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> <54D8B8A2.5070201@home.nl> <54D8C008.2080006@home.nl> <54D8C4F6.90201@gmail.com> <54D8C652.2060201@home.nl> Message-ID: <20150209152235.GA30525@fourtheye.org> On Mon, Feb 09, 2015 at 03:38:10PM +0100, Roelof Wobben wrote: > I know , the exercise is stated this : > > Write a function sum/1which, given a positive integer N, will return > the sum of all the > integers between 1 and N. > > Roelof If that is the problem, then the most effective way is to sum the Arithmetic progression? n * (n + 1) / 2 is the sum of an AP (IIRC). so sum(N) -> (((N + 1) * N) / 2) . which will be much faster than recursion ? Bob > Martin Koroudjiev schreef op 9-2-2015 om 15:32: > >It's perfect, just note that you will get "no function clause" exception > >if you pass negative number to the function which is probably desired > >result. > > > >Martin > > > >On 2/9/2015 4:11 PM, Roelof Wobben wrote: > >>Roelof Wobben schreef op 9-2-2015 om 14:39: > >>>sum(End) -> sum_acc(0, 0, End). > >>> > >>>sum_acc(Acc, _, 0) -> > >>> Acc; > >>>sum_acc(Acc, Current, Rem) -> > >>> sum_acc(Acc + Current, Current + 1, Rem - 1). > >> > >>A new try after some remarks : > >> > >>-module(sum_recursion). > >> > >>-export([sum/1]). > >> > >>% when the number is zero the outcome will also be zero > >>sum(0) -> > >> 0; > >> > >>% when a number is greater then 0 , call the helper function. > >>sum(End) when End > 0 -> > >> sum_acc(0, End). > >> > >>% When End is equal to zero all the numbers are added > >>sum_acc(Acc, 0) -> > >> Acc; > >> > >>% when end is not zero there are more numbers to be added. > >>sum_acc(Acc, End) -> > >> sum_acc(Acc + End, End - 1). > >> > >>Roelof > >>_______________________________________________ > >>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 roger@REDACTED Mon Feb 9 16:26:49 2015 From: roger@REDACTED (Roger Lipscombe) Date: Mon, 9 Feb 2015 15:26:49 +0000 Subject: [erlang-questions] Updating external references in Erlang docs In-Reply-To: References: Message-ID: If Erlang still runs on Windows 95 or 98 (or ME, ick), then that note is still important, since it's how you differentiate between that heritage and the NT one. If not, then I guess it should be dropped. The Unix one should probably be updated to compare a more-recent Solaris (11, apparently?) vs. OSX vs. Linux. On 6 February 2015 at 16:09, Derek Brown wrote: > There are numerous outdated references in the official documentation. > > For example: > http://www.erlang.org/doc/man/os.html#type-0 > > refers to Solaris 1 and 2, and Windows 95. Solaris 2 was updated by Solaris > 7 in 1998, and Windows 95 is from the same period. > > I've personally made numerous smaller doc changes, but submit for comment > more general ones such as these. > > Derek > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From r.wobben@REDACTED Mon Feb 9 16:27:11 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Mon, 09 Feb 2015 16:27:11 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: <20150209151810.GJ90397@ferdair.local> References: <54D88028.8000802@home.nl> <25E6B3BC-7693-4E0A-8895-20A61D26333E@masklinn.net> <54D8B8A2.5070201@home.nl> <54D8C008.2080006@home.nl> <20150209151810.GJ90397@ferdair.local> Message-ID: <54D8D1CF.6080003@home.nl> Fred Hebert schreef op 9-2-2015 om 16:18: > On 02/09, Roelof Wobben wrote: >> A new try after some remarks : >> >> % When End is equal to zero all the numbers are added >> sum_acc(Acc, 0) -> >> Acc; > The only criticism I'd have is that usually, Erlang programmers will put > the accumulator last in the list of arguments, and the variable you > iterate on in first positions. > > So the function clause above would be > > sum_acc(0, Acc) -> > Acc; > > Regards, > Fred. > Thanks, Changed it like this : -module(sum_recursion). -export([sum/1]). % when the number is zero the outcome will also be zero sum(0) -> 0; % when a number is greater then 0 , call the helper function. sum(End) when End > 0 -> sum_acc(End,0). % When End is equal to zero all the numbers are added sum_acc(0,Acc) -> Acc; % when end is not zero there are more numbers to be added. sum_acc(End, Acc) -> sum_acc(End - 1, Acc + End). Roelof From roberto@REDACTED Mon Feb 9 17:44:31 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Mon, 9 Feb 2015 17:44:31 +0100 Subject: [erlang-questions] Distributed Process Registry In-Reply-To: References: <54D7CC68.4010105@gmail.com> <32C204D4-9CE1-4D73-AC4F-43AF9808943A@widetag.com> <54D7D0B6.3090901@gmail.com> <03D8FB46-2E97-44C7-A795-B8899668FD74@widetag.com> Message-ID: On Mon, Feb 9, 2015 at 11:00 AM, Sergej Jure?ko wrote: > Now that we see how deep this rabbit hole goes. Would it perhaps be > feasible to only use a local registry on each node, then send every message > to both nodes. If a node does not have a process you're looking for > registered it just returns error or does nothing. > I'll evaluate options (benchmarks, etc), but indeed right now it seems that I'm back to my original custom solution. Thanks, r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From garret.smith@REDACTED Mon Feb 9 19:09:38 2015 From: garret.smith@REDACTED (Garret Smith) Date: Mon, 9 Feb 2015 10:09:38 -0800 Subject: [erlang-questions] New Erlang job openings In-Reply-To: <54D589F7.30702@bestmx.net> References: <54D3920E.6070901@bestmx.net> <20150207005704.GA1930@corelatus.se> <54D589F7.30702@bestmx.net> Message-ID: This particular one is an Erlang job, but we're willing to train a qualified candidate. Making Erlang "a plus" widens the candidate pool. On Fri, Feb 6, 2015 at 7:43 PM, e@REDACTED wrote: > i have found the missing link > https://erlangcentral.org/sr-software-engineer-synapsense/ > > this is definitely java job > Erlang is merely "a plus" > > > On 02/07/2015 01:57 AM, Matthias Lang wrote: >> >> On 05. February 2015, e@REDACTED wrote: >> >>> Hi, Bruce. >>> please, clarify the issue: >>> why erlangcentral allows non-erlang jobs to be posted? >>> >>> for example the following are C++ and Java positions: >>> >>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >>> >>> >>>> Software Engineer ? New Grad at ShoreTel - Canberra, Australia >>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >> >> >> 1. You've posted the same link twice. >> >> 2. The linked text says "The majority of the development work will >> be in C++ and Erlang." That sounds like an Erlang-related job to me. >> (Or was it ninja-edited?) >> >> Matt (not Bruce) >> > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From e@REDACTED Mon Feb 9 19:33:48 2015 From: e@REDACTED (e@REDACTED) Date: Mon, 09 Feb 2015 19:33:48 +0100 Subject: [erlang-questions] New Erlang job openings In-Reply-To: References: <54D3920E.6070901@bestmx.net> <20150207005704.GA1930@corelatus.se> <54D589F7.30702@bestmx.net> Message-ID: <54D8FD8C.6050004@bestmx.net> On 02/09/2015 07:09 PM, Garret Smith wrote: > This particular one is an Erlang job, but we're willing to train a > qualified candidate. so that was a sort of misunderstanding. your candidate will work with erlang, but you do not require specifically erlang background (smthng like: "any experience will suffice alongside the ability to learn") it might be a reason for erlangcentral.com to improve the format? an explicit list of tools and responsibilities? or smthng like that. > Making Erlang "a plus" widens the candidate > pool. i presume there are more people in the world who know Java than those who know Java AND Erlang. > On Fri, Feb 6, 2015 at 7:43 PM, e@REDACTED wrote: >> i have found the missing link >> https://erlangcentral.org/sr-software-engineer-synapsense/ >> >> this is definitely java job >> Erlang is merely "a plus" >> >> >> On 02/07/2015 01:57 AM, Matthias Lang wrote: >>> >>> On 05. February 2015, e@REDACTED wrote: >>> >>>> Hi, Bruce. >>>> please, clarify the issue: >>>> why erlangcentral allows non-erlang jobs to be posted? >>>> >>>> for example the following are C++ and Java positions: >>>> >>>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >>>> >>>> >>>>> Software Engineer ? New Grad at ShoreTel - Canberra, Australia >>>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >>> >>> >>> 1. You've posted the same link twice. >>> >>> 2. The linked text says "The majority of the development work will >>> be in C++ and Erlang." That sounds like an Erlang-related job to me. >>> (Or was it ninja-edited?) >>> >>> Matt (not Bruce) >>> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions From garret.smith@REDACTED Tue Feb 10 01:45:23 2015 From: garret.smith@REDACTED (Garret Smith) Date: Mon, 9 Feb 2015 16:45:23 -0800 Subject: [erlang-questions] New Erlang job openings In-Reply-To: References: <54D3920E.6070901@bestmx.net> <20150207005704.GA1930@corelatus.se> <54D589F7.30702@bestmx.net> <54D8FD8C.6050004@bestmx.net> Message-ID: On Mon, Feb 9, 2015 at 3:22 PM, Jason Duffy Smith wrote: > Hi All, > > I would just like to thank those at Erlang Central for maintain these > listings. Allowing a relaxed view on Erlang jobs means more options for > someone like myself looking for an "in". Especially being in remote > Australia were the listings are very sparse. > > So thank you for all the efforts. +1 Bruce saw the job posting and contacted me to get it on Erlang Central. That was awesome! > > - Jason > (I don't say much in this community but felt a thank you was warranted) > > > On 10 February 2015 at 05:33, e@REDACTED wrote: >> >> On 02/09/2015 07:09 PM, Garret Smith wrote: >>> >>> This particular one is an Erlang job, but we're willing to train a >>> qualified candidate. >> >> >> so that was a sort of misunderstanding. >> your candidate will work with erlang, but you do not require specifically >> erlang background (smthng like: "any experience will suffice alongside the >> ability to learn") >> >> it might be a reason for erlangcentral.com to improve the format? >> an explicit list of tools and responsibilities? or smthng like that. >> >> >>> Making Erlang "a plus" widens the candidate >>> pool. >> >> >> i presume there are more people in the world who know Java than those who >> know Java AND Erlang. >> >> >> >> >>> On Fri, Feb 6, 2015 at 7:43 PM, e@REDACTED wrote: >>>> >>>> i have found the missing link >>>> https://erlangcentral.org/sr-software-engineer-synapsense/ >>>> >>>> this is definitely java job >>>> Erlang is merely "a plus" >>>> >>>> >>>> On 02/07/2015 01:57 AM, Matthias Lang wrote: >>>>> >>>>> >>>>> On 05. February 2015, e@REDACTED wrote: >>>>> >>>>>> Hi, Bruce. >>>>>> please, clarify the issue: >>>>>> why erlangcentral allows non-erlang jobs to be posted? >>>>>> >>>>>> for example the following are C++ and Java positions: >>>>>> >>>>>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >>>>>> >>>>>> >>>>>> >>>>>>> Software Engineer ? New Grad at ShoreTel - Canberra, Australia >>>>>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >>>>> >>>>> >>>>> >>>>> 1. You've posted the same link twice. >>>>> >>>>> 2. The linked text says "The majority of the development work will >>>>> be in C++ and Erlang." That sounds like an Erlang-related job to >>>>> me. >>>>> (Or was it ninja-edited?) >>>>> >>>>> Matt (not Bruce) >>>>> >>>> _______________________________________________ >>>> 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 jason.nevar.smith@REDACTED Tue Feb 10 00:22:06 2015 From: jason.nevar.smith@REDACTED (Jason Duffy Smith) Date: Tue, 10 Feb 2015 10:22:06 +1100 Subject: [erlang-questions] New Erlang job openings In-Reply-To: <54D8FD8C.6050004@bestmx.net> References: <54D3920E.6070901@bestmx.net> <20150207005704.GA1930@corelatus.se> <54D589F7.30702@bestmx.net> <54D8FD8C.6050004@bestmx.net> Message-ID: Hi All, I would just like to thank those at Erlang Central for maintain these listings. Allowing a relaxed view on Erlang jobs means more options for someone like myself looking for an "in". Especially being in remote Australia were the listings are very sparse. So thank you for all the efforts. - Jason (I don't say much in this community but felt a thank you was warranted) On 10 February 2015 at 05:33, e@REDACTED wrote: > On 02/09/2015 07:09 PM, Garret Smith wrote: > >> This particular one is an Erlang job, but we're willing to train a >> qualified candidate. >> > > so that was a sort of misunderstanding. > your candidate will work with erlang, but you do not require specifically > erlang background (smthng like: "any experience will suffice alongside the > ability to learn") > > it might be a reason for erlangcentral.com to improve the format? > an explicit list of tools and responsibilities? or smthng like that. > > > Making Erlang "a plus" widens the candidate >> pool. >> > > i presume there are more people in the world who know Java than those who > know Java AND Erlang. > > > > > On Fri, Feb 6, 2015 at 7:43 PM, e@REDACTED wrote: >> >>> i have found the missing link >>> https://erlangcentral.org/sr-software-engineer-synapsense/ >>> >>> this is definitely java job >>> Erlang is merely "a plus" >>> >>> >>> On 02/07/2015 01:57 AM, Matthias Lang wrote: >>> >>>> >>>> On 05. February 2015, e@REDACTED wrote: >>>> >>>> Hi, Bruce. >>>>> please, clarify the issue: >>>>> why erlangcentral allows non-erlang jobs to be posted? >>>>> >>>>> for example the following are C++ and Java positions: >>>>> >>>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >>>>>> >>>>> >>>>> >>>>> Software Engineer ? New Grad at ShoreTel - Canberra, Australia >>>>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >>>>>> >>>>> >>>> >>>> 1. You've posted the same link twice. >>>> >>>> 2. The linked text says "The majority of the development work will >>>> be in C++ and Erlang." That sounds like an Erlang-related job to >>>> me. >>>> (Or was it ninja-edited?) >>>> >>>> Matt (not Bruce) >>>> >>>> _______________________________________________ >>> 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 r.wobben@REDACTED Tue Feb 10 09:01:49 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Tue, 10 Feb 2015 09:01:49 +0100 Subject: [erlang-questions] head mismatch Message-ID: <54D9BAED.8050406@home.nl> An HTML attachment was scrubbed... URL: From bob@REDACTED Tue Feb 10 09:06:40 2015 From: bob@REDACTED (Bob Ippolito) Date: Tue, 10 Feb 2015 00:06:40 -0800 Subject: [erlang-questions] head mismatch In-Reply-To: <54D9BAED.8050406@home.nl> References: <54D9BAED.8050406@home.nl> Message-ID: On Tue, Feb 10, 2015 at 12:01 AM, Roelof Wobben wrote: > Am I not alllowed to do this > > sum(x) -> > x ; > > sum(x,y) -> > x + y. > > or is there something else missing ? > That's correct. Those are two different functions, so a period rather than semicolon should be used. In Erlang, functions in a module are identified by their name and their arity (the number of arguments they take). The first function would be sum/1 and the second is sum/2. -bob -------------- next part -------------- An HTML attachment was scrubbed... URL: From bengt.kleberg@REDACTED Tue Feb 10 09:06:53 2015 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 10 Feb 2015 09:06:53 +0100 Subject: [erlang-questions] head mismatch In-Reply-To: <54D9BAED.8050406@home.nl> References: <54D9BAED.8050406@home.nl> Message-ID: <54D9BC1D.7060800@ericsson.com> You are correct it is nopt possibler to have sum/1 followed by sum/2 with an ";" between them. They are different functions that happen to have the same name. But since the arity (number of arguments) is different they are different. bengt On 02/10/2015 09:01 AM, Roelof Wobben wrote: > Hello, > > I changed my code so that it also can count from a number to a number, > so sum(3,6) does 3+4+5+6 and sum(2) does 0+1+2 > > I now have this : > > -module(sum_recursion). > > -export([sum/1, sum/2]). > > % when the number is zero the outcome will also be zero > sum(0) -> > 0; > > % when a number is greater then 0 , call the helper function. > sum(End) when End > 0 -> > sum_acc(End,0); > > % when the first number is greater then zero and lower then the second > number > sum(Begin, End) when Begin >= 0 , Begin =< End -> > sum_acc(Begin, End, Begin). > > % When End is equal to zero all the numbers are added > sum_acc(0,Acc) -> > Acc; > > % When End is equal to Begin all numbers are added. > sum_acc(Begin, Begin, Acc) -> > Acc ; > > % when end is not zero there are more numbers to be added. > sum_acc(End, Acc) -> > sum_acc(End - 1, Acc + End); > > % When end is not equal to begin then there are more numbers to be added. > sum_acc(Begin, End, Acc) -> > sum_acc(Begin, End - 1, Acc + End). > > > but as soon as I try to compile it I see this error : > > error > 7> c(sum_recursion). > sum_recursion.erl:14: head mismatch > sum_recursion.erl:22: head mismatch > sum_recursion.erl:3: function sum/1 undefined > sum_recursion.erl:3: function sum/2 undefined > > Am I not alllowed to do this > > sum(x) -> > x ; > > sum(x,y) -> > x + y. > > or is there something else missing ? > > Roelof > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben@REDACTED Tue Feb 10 09:12:17 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Tue, 10 Feb 2015 09:12:17 +0100 Subject: [erlang-questions] head mismatch In-Reply-To: <54D9BC1D.7060800@ericsson.com> References: <54D9BAED.8050406@home.nl> <54D9BC1D.7060800@ericsson.com> Message-ID: <54D9BD61.1000005@home.nl> An HTML attachment was scrubbed... URL: From lamchith@REDACTED Tue Feb 10 09:46:03 2015 From: lamchith@REDACTED (Lamchith M C) Date: Tue, 10 Feb 2015 14:16:03 +0530 Subject: [erlang-questions] xml creation Message-ID: I want to create Following xml . 1 dif>1 I am trying it with following code, but getting error. serialize(Data) -> Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)), io:format("~s~n", [Xml]). test7(UId,DId) -> RootElem = {configuration, [{uid, [UId]},{dif, [DId]}]}, serialize([RootElem]). by calling test7(1,1) Please help. -- Regards, Lamchith -------------- next part -------------- An HTML attachment was scrubbed... URL: From dm.klionsky@REDACTED Tue Feb 10 10:50:38 2015 From: dm.klionsky@REDACTED (Dmitry Klionsky) Date: Tue, 10 Feb 2015 12:50:38 +0300 Subject: [erlang-questions] xml creation In-Reply-To: References: Message-ID: <54D9D46E.40800@gmail.com> test7('1', "1") works because the simplest Content's element should be IOString. http://www.erlang.org/doc/man/xmerl.html#export_simple-3 On 02/10/2015 11:46 AM, Lamchith M C wrote: > I want to create Following xml . > > > > 1 > dif>1 > > > I am trying it with following code, but getting error. > > serialize(Data) -> > Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)), > io:format("~s~n", [Xml]). > > test7(UId,DId) -> > RootElem = {configuration, > [{uid, [UId]},{dif, [DId]}]}, > serialize([RootElem]). > > by calling test7(1,1) > > Please help. > > -- > Regards, > Lamchith > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From dm.klionsky@REDACTED Tue Feb 10 11:40:50 2015 From: dm.klionsky@REDACTED (Dmitry Klionsky) Date: Tue, 10 Feb 2015 13:40:50 +0300 Subject: [erlang-questions] xml creation In-Reply-To: References: <54D9D46E.40800@gmail.com> Message-ID: <54D9E032.1070305@gmail.com> Not sure what you mean, but I'm trying to say that Uid and Did should be atoms or strings. On 02/10/2015 01:34 PM, Lamchith M C wrote: > So i can not make this parametric? So that by calling the > test7(UId,DId) functions with different variables to create different xml. > > On Tue, Feb 10, 2015 at 3:20 PM, Dmitry Klionsky > > wrote: > > test7('1', "1") works because the simplest Content's element > should be IOString. > http://www.erlang.org/doc/man/xmerl.html#export_simple-3 > > > On 02/10/2015 11:46 AM, Lamchith M C wrote: >> I want to create Following xml . >> >> >> >> 1 >> dif>1 >> >> >> I am trying it with following code, but getting error. >> >> serialize(Data) -> >> Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)), >> io:format("~s~n", [Xml]). >> >> test7(UId,DId) -> >> RootElem = {configuration, >> [{uid, [UId]},{dif, [DId]}]}, >> serialize([RootElem]). >> >> by calling test7(1,1) >> >> Please help. >> >> -- >> Regards, >> Lamchith >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > > -- > Regards, > Lamchith -------------- next part -------------- An HTML attachment was scrubbed... URL: From eric.pailleau@REDACTED Tue Feb 10 12:33:06 2015 From: eric.pailleau@REDACTED (Eric Pailleau) Date: Tue, 10 Feb 2015 12:33:06 +0100 Subject: [erlang-questions] xml creation Message-ID: missing opening < in dif tag. ? Envoy? depuis mon mobile ? Eric Lamchith M C a ?crit?: >I want to create Following xml . > > > >1 >dif>1 > > >I am trying it with following code, but getting error. > >serialize(Data) -> > Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)), > io:format("~s~n", [Xml]). > >test7(UId,DId) -> > RootElem = {configuration, > [{uid, [UId]},{dif, [DId]}]}, > serialize([RootElem]). > >by calling test7(1,1) > >Please help. > >-- >Regards, >Lamchith > >_______________________________________________ >erlang-questions mailing list >erlang-questions@REDACTED >http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From dm.klionsky@REDACTED Tue Feb 10 12:39:34 2015 From: dm.klionsky@REDACTED (Dmitry Klionsky) Date: Tue, 10 Feb 2015 14:39:34 +0300 Subject: [erlang-questions] xml creation In-Reply-To: References: <54D9D46E.40800@gmail.com> <54D9E032.1070305@gmail.com> Message-ID: <54D9EDF6.4030402@gmail.com> No, your function should be like: test7(UId,DId) when is_integer(Uid), is_integer(Did) -> RootElem = {configuration, [{uid, [integer_to_list(UId)]},{dif, [integer_to_list(DId)]}]}, serialize([RootElem]). On 02/10/2015 01:53 PM, Lamchith M C wrote: > Thanks, got it, where i am calling the function i will call with > parameters surrounded by " ". I was trying that inside the function, > which was failing like below > > > RootElem = {configuration, > [{uid, ["UId"]},{dif, ["DId"]}]}, > > On Tue, Feb 10, 2015 at 4:10 PM, Dmitry Klionsky > > wrote: > > Not sure what you mean, but I'm trying to say that Uid and Did > should be atoms or strings. > > > > On 02/10/2015 01:34 PM, Lamchith M C wrote: >> So i can not make this parametric? So that by calling the >> test7(UId,DId) functions with different variables to create >> different xml. >> >> On Tue, Feb 10, 2015 at 3:20 PM, Dmitry Klionsky >> > wrote: >> >> test7('1', "1") works because the simplest Content's element >> should be IOString. >> http://www.erlang.org/doc/man/xmerl.html#export_simple-3 >> >> >> On 02/10/2015 11:46 AM, Lamchith M C wrote: >>> I want to create Following xml . >>> >>> >>> >>> 1 >>> dif>1 >>> >>> >>> I am trying it with following code, but getting error. >>> >>> serialize(Data) -> >>> Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)), >>> io:format("~s~n", [Xml]). >>> >>> test7(UId,DId) -> >>> RootElem = {configuration, >>> [{uid, [UId]},{dif, [DId]}]}, >>> serialize([RootElem]). >>> >>> by calling test7(1,1) >>> >>> Please help. >>> >>> -- >>> Regards, >>> Lamchith >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >> >> >> >> >> -- >> Regards, >> Lamchith > > > > > -- > Regards, > Lamchith -------------- next part -------------- An HTML attachment was scrubbed... URL: From lamchith@REDACTED Tue Feb 10 11:34:51 2015 From: lamchith@REDACTED (Lamchith M C) Date: Tue, 10 Feb 2015 16:04:51 +0530 Subject: [erlang-questions] xml creation In-Reply-To: <54D9D46E.40800@gmail.com> References: <54D9D46E.40800@gmail.com> Message-ID: So i can not make this parametric? So that by calling the test7(UId,DId) functions with different variables to create different xml. On Tue, Feb 10, 2015 at 3:20 PM, Dmitry Klionsky wrote: > test7('1', "1") works because the simplest Content's element should be IOString. > > http://www.erlang.org/doc/man/xmerl.html#export_simple-3 > > > On 02/10/2015 11:46 AM, Lamchith M C wrote: > > I want to create Following xml . > > > > 1 > dif>1 > > > I am trying it with following code, but getting error. > > serialize(Data) -> > Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)), > io:format("~s~n", [Xml]). > > test7(UId,DId) -> > RootElem = {configuration, > [{uid, [UId]},{dif, [DId]}]}, > serialize([RootElem]). > > by calling test7(1,1) > > Please help. > > -- > Regards, > Lamchith > > > _______________________________________________ > erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions > > > -- Regards, Lamchith -------------- next part -------------- An HTML attachment was scrubbed... URL: From lamchith@REDACTED Tue Feb 10 11:53:03 2015 From: lamchith@REDACTED (Lamchith M C) Date: Tue, 10 Feb 2015 16:23:03 +0530 Subject: [erlang-questions] xml creation In-Reply-To: <54D9E032.1070305@gmail.com> References: <54D9D46E.40800@gmail.com> <54D9E032.1070305@gmail.com> Message-ID: Thanks, got it, where i am calling the function i will call with parameters surrounded by " ". I was trying that inside the function, which was failing like below RootElem = {configuration, [{uid, ["UId"]},{dif, ["DId"]}]}, On Tue, Feb 10, 2015 at 4:10 PM, Dmitry Klionsky wrote: > Not sure what you mean, but I'm trying to say that Uid and Did should be > atoms or strings. > > > > On 02/10/2015 01:34 PM, Lamchith M C wrote: > > So i can not make this parametric? So that by calling the test7(UId,DId) > functions with different variables to create different xml. > > On Tue, Feb 10, 2015 at 3:20 PM, Dmitry Klionsky > wrote: > >> test7('1', "1") works because the simplest Content's element should be IOString. >> >> http://www.erlang.org/doc/man/xmerl.html#export_simple-3 >> >> >> On 02/10/2015 11:46 AM, Lamchith M C wrote: >> >> I want to create Following xml . >> >> >> >> 1 >> dif>1 >> >> >> I am trying it with following code, but getting error. >> >> serialize(Data) -> >> Xml = lists:flatten(xmerl:export_simple(Data, xmerl_xml)), >> io:format("~s~n", [Xml]). >> >> test7(UId,DId) -> >> RootElem = {configuration, >> [{uid, [UId]},{dif, [DId]}]}, >> serialize([RootElem]). >> >> by calling test7(1,1) >> >> Please help. >> >> -- >> Regards, >> Lamchith >> >> >> _______________________________________________ >> erlang-questions mailing listerlang-questions@REDACTED://erlang.org/mailman/listinfo/erlang-questions >> >> >> > > > -- > Regards, > Lamchith > > > -- Regards, Lamchith -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Tue Feb 10 13:12:35 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Tue, 10 Feb 2015 13:12:35 +0100 Subject: [erlang-questions] Mnesia fastest select on secondary index Message-ID: Dear list, What is the easiest / most proper way to do the equivalent of a mnesia:dirty_read on a secondary index? I have a standard table: -record(my_records, { primary, secondary }). mnesia:create_table(my_records, [ {type, set}, {ram_copies, [node()]}, {attributes, record_info(fields, my_records)}, {index, [#my_record.secondary]} ]). On a primary key it's obviously trivial: mnesia:dirty_read(my_record, <<"1">>). What is the recommended way (and fastest, dirty are desired, inconsistency is ok in the system) to retrieve the record with secondary = <<"a">>? Best, r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From howard.goodkind@REDACTED Tue Feb 10 13:31:40 2015 From: howard.goodkind@REDACTED (Howard Goodkind (Accion Labs UK)) Date: Tue, 10 Feb 2015 12:31:40 -0000 Subject: [erlang-questions] new Erlang Practice! Message-ID: <00c401d0452d$85c37b10$914a7130$@accionlabs.com> AccionLabs are building a Global distributed Erlang practice in the UK, India & Singapore. We are seeing increasing demand from customers with Erlang projects, and wish to be their provider of choice both in the UK and off-shore to capture the best talent & cost advantages. Please get in touch for an informal chat if you are considering a career change, we are also holding talks with experienced Erlang contractors to help out on immediate project opportunities. Accion Labs is a Global technology services company, 700+ staff with 10 Int'l offices. We are a forward thinking, agile company, specialising in the latest emerging technology services like Big Data, Cloud, Open Source, SaaS, Complex integration, Web, Mobile, DW. You can gain exposure to these technologies both in the UK and from one of our Global centres. referral scheme applies if you can help us build an Erlang team! contact: AccionLabs UK MD Howard Goodkind: 02089547077 or howard.goodkind@REDACTED Background on AccionLabs: AccionLabs: est 2011, $30M turnover, Global Technology services, 600+ staff, 10 International offices (UK, Asia, US, Middle East), H/Q Pittsburgh USA. Steady & growing customer base, privately invested recently raised 2nd round of funding. Founded and Led by Technologists, Outcome focused. Specialise in Emerging technologies, with a portfolio of services: . RIA (Rich internet applications) / SaaS . Cloud . Mobility . Analytics / Big Data . QA / Automation . Open source . ITOM . Trading, Risk, Pricing expertise, cross asset front to back What do we do: New software & application product development, Migrations, Trading, Risk, & Pricing Upgrades, Technology Alignment & selection, Application development & testing, professional services, mobile & cloud enablement. Who are our clients: Start-ups to large Enterprises Software development: Current best practices like Agile, TDD (test driven development) BDD (Behavioural driven development) How do we engage: Turn key projects (managed by you, managed by us, or hybrid), Off shore leveraged extended teams, Professional Services, Technology recommendations & implementation What differentiates us: Solutions centric approach (technology selection with our innovation team, e.g content management, ecommerce platform, JIRA (issue / product tracking solution) Led by technologists, outcome focused With kind regards, Howard Goodkind Managing Director Accion Labs (UK) Limited - Europe Global Technology Services UK Office 00442089547077 / Cell 00447989566941 Howard.goodkind@REDACTED www.linkedin.com/in/accionlabs www.accionlabs.com ____________________________________________________________________________ ____________________________________________________________________________ ______ Driving Outcomes Through Actions! Accion Labs is a global technology services firm with focus on serving technology & enterprise firms in the emerging technologies such as Web 2.0, Open Source, SaaS/Cloud, e-Commerce, Mobility, Big Data and BI/DW. With 10 global offices and a rapid-response delivery model, Accion offers a range of engagement models such as turn-key projects, extended-teams, shared-IP development, offshore-leveraged engagements and professional staffing (contract, contract-to-hire & direct perm). Accion Labs is privately-held, venture-funded and has a hands-on management that believes in execution and outcome. Pittsburgh | Atlanta | Santa Clara | Bangalore | Mumbai | Singapore | Malaysia | London ____________________________________________________________________________ ____________________________________________________________________________ __________________________________________________________ Accion Labs UK Limited DISCLAIMER: This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error, please notify us immediately and delete the email and any attachments from your system. The recipient should check this email and any attachments for the presence of viruses. Accion Labs UK Limited accepts no liability for any damage caused by any virus transmitted by this email, makes no warranty as to the accuracy or completeness of this email and hereby disclaims any liability of any kind for the information contained herein. Unless otherwise agreed between the client and a legal representative of our company, i.e a Director, all placements made by Accion Labs UK Limited are made on our standard terms of business for clients. By virtue of receipt of this email introduction to the attached candidate, the client agrees to our terms, a copy of which is attached to this email or will be sent with an appropriate cv. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ulf@REDACTED Tue Feb 10 13:56:09 2015 From: ulf@REDACTED (Ulf Wiger) Date: Tue, 10 Feb 2015 13:56:09 +0100 Subject: [erlang-questions] Mnesia fastest select on secondary index In-Reply-To: References: Message-ID: <0BE67EEE-7D1D-44D9-99A5-AAD9C6D248FF@feuerlabs.com> > On 10 Feb 2015, at 13:12, Roberto Ostinelli wrote: > > What is the recommended way (and fastest, dirty are desired, inconsistency is ok in the system) to retrieve the record with secondary = <<"a">>? That would be mnesia:dirty_index_read(Tab, Value, IndexPos). Eshell V5.10.3 (abort with ^G) 1> rd(my_records,{primary,secondary}). my_records 2> #my_records{}. #my_records{primary = undefined,secondary = undefined} 3> mnesia:start(). ok 4> mnesia:create_table(my_records,[{type,set},{ram_copies,[node()]},{attributes,record_info(fields,my_records)},{index,[#my_records.secondary]}]). {atomic,ok} 5> mnesia:dirty_write(#my_records{primary = <<"1">>, secondary = <<"a">>}). ok 6> mnesia:dirty_read({my_records,<<"1">>}). [#my_records{primary = <<"1">>,secondary = <<"a">>}] 7> mnesia:dirty_index_read(my_records,<<"a">>,#my_records.secondary). [#my_records{primary = <<"1">>,secondary = <<"a">>}] 8> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]). {304,[#my_records{primary = <<"1">>,secondary = <<"a">>}]} 9> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]). {28,[#my_records{primary = <<"1">>,secondary = <<"a">>}]} 10> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]). {37,[#my_records{primary = <<"1">>,secondary = <<"a">>}]} BR, Ulf W Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. http://feuerlabs.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto.ostinelli@REDACTED Tue Feb 10 14:07:52 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Tue, 10 Feb 2015 14:07:52 +0100 Subject: [erlang-questions] Mnesia fastest select on secondary index In-Reply-To: <0BE67EEE-7D1D-44D9-99A5-AAD9C6D248FF@feuerlabs.com> References: <0BE67EEE-7D1D-44D9-99A5-AAD9C6D248FF@feuerlabs.com> Message-ID: Thank you Ulf. :) I was benchmarking selects and match_objects, looks like this is indeed the best option. Cheers, r. > On 10/feb/2015, at 13:56, Ulf Wiger wrote: > > >> On 10 Feb 2015, at 13:12, Roberto Ostinelli wrote: >> >> What is the recommended way (and fastest, dirty are desired, inconsistency is ok in the system) to retrieve the record with secondary = <<"a">>? > > That would be mnesia:dirty_index_read(Tab, Value, IndexPos). > > Eshell V5.10.3 (abort with ^G) > 1> rd(my_records,{primary,secondary}). > my_records > 2> #my_records{}. > #my_records{primary = undefined,secondary = undefined} > 3> mnesia:start(). > ok > 4> mnesia:create_table(my_records,[{type,set},{ram_copies,[node()]},{attributes,record_info(fields,my_records)},{index,[#my_records.secondary]}]). > {atomic,ok} > 5> mnesia:dirty_write(#my_records{primary = <<"1">>, secondary = <<"a">>}). > ok > 6> mnesia:dirty_read({my_records,<<"1">>}). > [#my_records{primary = <<"1">>,secondary = <<"a">>}] > 7> mnesia:dirty_index_read(my_records,<<"a">>,#my_records.secondary). > [#my_records{primary = <<"1">>,secondary = <<"a">>}] > 8> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]). > {304,[#my_records{primary = <<"1">>,secondary = <<"a">>}]} > 9> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]). > {28,[#my_records{primary = <<"1">>,secondary = <<"a">>}]} > 10> timer:tc(mnesia,dirty_index_read,[my_records,<<"a">>,#my_records.secondary]). > {37,[#my_records{primary = <<"1">>,secondary = <<"a">>}]} > > > BR, > Ulf W > > Ulf Wiger, Co-founder & Developer Advocate, Feuerlabs Inc. > http://feuerlabs.com > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Tue Feb 10 14:20:45 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Tue, 10 Feb 2015 14:20:45 +0100 Subject: [erlang-questions] Mnesia create tables best practices In-Reply-To: <87467EDF-C075-4F77-8993-C4108D2432A6@widetag.com> References: <87467EDF-C075-4F77-8993-C4108D2432A6@widetag.com> Message-ID: On Sun, Feb 8, 2015 at 7:25 PM, Roberto Ostinelli < roberto.ostinelli@REDACTED> wrote: > Can you please expand on this? Do you mean that when you boot a system you > reset the db? The DB is never reset. It is just that on the first deploy, there is a valid DB the system can use to start up and get to work. Apart from having the right schema, it can also be pre-populated with important data the systems needs in order to function correctly. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben@REDACTED Tue Feb 10 15:19:45 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Tue, 10 Feb 2015 15:19:45 +0100 Subject: [erlang-questions] output [[[[]|2]|1]|0] instead of [2.1.0] Message-ID: <54DA1381.8030605@home.nl> Hello, I have to make a reversed list to a number so reverse_list(2) will output [2.1] I have this code : -module(list_creation). -export([create/1, create_reverse/1]). create(Number) when Number >= 0 -> create_acc(Number,[]). create_acc(-1,Acc) -> Acc; create_acc(Number, Acc) -> create_acc(Number -1, [Number | Acc]). create_reverse(Number) when Number >= 0 -> create_reverse_acc(Number, []). create_reverse_acc(-1, Acc) -> Acc; create_reverse_acc(Number,Acc) -> create_reverse_acc(Number - 1, [Acc] ++ Number). but when I do create_reverse(2) I see this output [[[[]|2]|1]|0] instead of [2,1,0] Does the ++ always produce this when adding a item to a list ? Roelof From bengt.kleberg@REDACTED Tue Feb 10 15:27:21 2015 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Tue, 10 Feb 2015 15:27:21 +0100 Subject: [erlang-questions] output [[[[]|2]|1]|0] instead of [2.1.0] In-Reply-To: <54DA1381.8030605@home.nl> References: <54DA1381.8030605@home.nl> Message-ID: <54DA1549.5050603@ericsson.com> ++ is used to concatenate lists. Acc is a list, so you do not need to add [] around it. Number is not a list, so you need to add [] around it. bengt On 02/10/2015 03:19 PM, Roelof Wobben wrote: > Hello, > > I have to make a reversed list to a number so reverse_list(2) will > output [2.1] > > I have this code : > > -module(list_creation). > > -export([create/1, create_reverse/1]). > > create(Number) when Number >= 0 -> > create_acc(Number,[]). > > create_acc(-1,Acc) -> > Acc; > > create_acc(Number, Acc) -> > create_acc(Number -1, [Number | Acc]). > > create_reverse(Number) when Number >= 0 -> > create_reverse_acc(Number, []). > > create_reverse_acc(-1, Acc) -> > Acc; > > create_reverse_acc(Number,Acc) -> > create_reverse_acc(Number - 1, [Acc] ++ Number). > > > but when I do create_reverse(2) I see this output [[[[]|2]|1]|0] > instead of [2,1,0] > > Does the ++ always produce this when adding a item to a list ? > > Roelof > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From essen@REDACTED Tue Feb 10 15:42:23 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Tue, 10 Feb 2015 15:42:23 +0100 Subject: [erlang-questions] output [[[[]|2]|1]|0] instead of [2.1.0] In-Reply-To: <54DA1381.8030605@home.nl> References: <54DA1381.8030605@home.nl> Message-ID: <54DA18CF.3030202@ninenines.eu> You are creating what is called an improper list. This is a proper list: [1,2,3] This is the same list using the | operator: [1|[2|[3]]] Now what happens if you write this, for example? [1,2|3] It still works. This is called an improper list. An improper list is a list where the tail is not a list. When you do A++B Erlang will only ensure that A is a list. B can be anything. If it's not a list, however, then you end up with an improper list. I advise you to avoid ++ when doing most list related exercices, go with the | operator instead. On 02/10/2015 03:19 PM, Roelof Wobben wrote: > Hello, > > I have to make a reversed list to a number so reverse_list(2) will > output [2.1] ... -- Lo?c Hoguin http://ninenines.eu From essen@REDACTED Tue Feb 10 15:45:39 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Tue, 10 Feb 2015 15:45:39 +0100 Subject: [erlang-questions] output [[[[]|2]|1]|0] instead of [2.1.0] In-Reply-To: <54DA18CF.3030202@ninenines.eu> References: <54DA1381.8030605@home.nl> <54DA18CF.3030202@ninenines.eu> Message-ID: <54DA1993.2070005@ninenines.eu> On 02/10/2015 03:42 PM, Lo?c Hoguin wrote: > You are creating what is called an improper list. > > This is a proper list: > > [1,2,3] > > This is the same list using the | operator: > > [1|[2|[3]]] > > Now what happens if you write this, for example? > > [1,2|3] > > It still works. This is called an improper list. An improper list is a > list where the tail is not a list. Forgot to say that most lists functions expect proper lists and will fail when they encounter an improper list, including the length/1 function. Cheers. > When you do A++B Erlang will only ensure that A is a list. B can be > anything. If it's not a list, however, then you end up with an improper > list. > > I advise you to avoid ++ when doing most list related exercices, go with > the | operator instead. > > On 02/10/2015 03:19 PM, Roelof Wobben wrote: >> Hello, >> >> I have to make a reversed list to a number so reverse_list(2) will >> output [2.1] > ... > -- Lo?c Hoguin http://ninenines.eu From r.wobben@REDACTED Tue Feb 10 15:58:39 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Tue, 10 Feb 2015 15:58:39 +0100 Subject: [erlang-questions] output [[[[]|2]|1]|0] instead of [2.1.0] In-Reply-To: <54DA1993.2070005@ninenines.eu> References: <54DA1381.8030605@home.nl> <54DA18CF.3030202@ninenines.eu> <54DA1993.2070005@ninenines.eu> Message-ID: <54DA1C9F.7030506@home.nl> Lo?c Hoguin schreef op 10-2-2015 om 15:45: > On 02/10/2015 03:42 PM, Lo?c Hoguin wrote: >> You are creating what is called an improper list. >> >> This is a proper list: >> >> [1,2,3] >> >> This is the same list using the | operator: >> >> [1|[2|[3]]] >> >> Now what happens if you write this, for example? >> >> [1,2|3] >> >> It still works. This is called an improper list. An improper list is a >> list where the tail is not a list. > > Forgot to say that most lists functions expect proper lists and will > fail when they encounter an improper list, including the length/1 > function. > > Cheers. > >> When you do A++B Erlang will only ensure that A is a list. B can be >> anything. If it's not a list, however, then you end up with an improper >> list. >> >> I advise you to avoid ++ when doing most list related exercices, go with >> the | operator instead. >> >> On 02/10/2015 03:19 PM, Roelof Wobben wrote: >>> Hello, >>> >>> I have to make a reversed list to a number so reverse_list(2) will >>> output [2.1] >> ... >> > Hello, Thanks both for the explanation. I will rewrite the code to use | instead of ++ Roelof From r.wobben@REDACTED Tue Feb 10 16:05:12 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Tue, 10 Feb 2015 16:05:12 +0100 Subject: [erlang-questions] output [[[[]|2]|1]|0] instead of [2.1.0] In-Reply-To: <54DA1C9F.7030506@home.nl> References: <54DA1381.8030605@home.nl> <54DA18CF.3030202@ninenines.eu> <54DA1993.2070005@ninenines.eu> <54DA1C9F.7030506@home.nl> Message-ID: <54DA1E28.9000908@home.nl> Roelof Wobben schreef op 10-2-2015 om 15:58: > Lo?c Hoguin schreef op 10-2-2015 om 15:45: >> On 02/10/2015 03:42 PM, Lo?c Hoguin wrote: >>> You are creating what is called an improper list. >>> >>> This is a proper list: >>> >>> [1,2,3] >>> >>> This is the same list using the | operator: >>> >>> [1|[2|[3]]] >>> >>> Now what happens if you write this, for example? >>> >>> [1,2|3] >>> >>> It still works. This is called an improper list. An improper list is a >>> list where the tail is not a list. >> >> Forgot to say that most lists functions expect proper lists and will >> fail when they encounter an improper list, including the length/1 >> function. >> >> Cheers. >> >>> When you do A++B Erlang will only ensure that A is a list. B can be >>> anything. If it's not a list, however, then you end up with an improper >>> list. >>> >>> I advise you to avoid ++ when doing most list related exercices, go >>> with >>> the | operator instead. >>> >>> On 02/10/2015 03:19 PM, Roelof Wobben wrote: >>>> Hello, >>>> >>>> I have to make a reversed list to a number so reverse_list(2) will >>>> output [2.1] >>> ... >>> >> > > Hello, > > Thanks both for the explanation. > I will rewrite the code to use | instead of ++ > > Roelof > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions Then I hope this solution is well written : -module(list_creation). -export([create/1, create_reverse/1]). create(Number) when Number > 0 -> create_acc(Number,[]). create_acc(0,Acc) -> Acc; create_acc(Number, Acc) -> create_acc(Number -1, [Number | Acc]). create_reverse(Number) when Number > 0 -> create_reverse_acc(Number, 1, []). create_reverse_acc(Endnumber, Endnumber, Acc) -> [Endnumber | Acc ]; create_reverse_acc(Endnumber,Current, Acc) -> create_reverse_acc(Endnumber, Current + 1, [Current | Acc ]). Roelof From Andras.Bekes@REDACTED Tue Feb 10 14:39:42 2015 From: Andras.Bekes@REDACTED (Bekes, Andras G) Date: Tue, 10 Feb 2015 13:39:42 +0000 Subject: [erlang-questions] {error,closed} vs. {error,econnreset} Message-ID: Hi All, Looks like I have a problem with the erroneous result of gen_tcp:recv/2, as it returns {error,closed} instead of my expectation of {error,econnreset}. I can reproduce my problem by: 1, starting a server application and forcing it into a busy state when it is listening but not accepting connections 2,starting 1000 clients (in Erlang) that connect to the server, filling the TCP listen backlog of the server. When the backlog is filled and after some time (~2 minutes), the Erlang connections return {error,closed}. This is what I do in Erlang: fun()->{ok,Socket}= TCPCONNECT(HOST,PORT), ok=gen_tcp:send(Socket,<<"SOMEDATA...">>), io:format("~p:~p\n",[self(),gen_tcp:recv(Socket,100)]) end. spawn this 1000 times. 3, a native client of the service however tells me that the connection was reset by peer. According to strace, it executes a recvfrom which returns ECONNRESET: recvfrom(...) = -1 ECONNRESET (Connection reset by peer) I also straced the Erlang beam process and it indeed gets an ECONNRESET result for the recvfrom call, but the Erlang return value is {error,closed}. Unfortunately it looks like I really need to separate these two results. I also tried gen_tcp in active mode, but no difference, the result is {error,closed} instead of {error,econnreset}. Can someone explain why the econnreset error is masked? Is there any way I can separate the two kinds of events? Thanks, Andras G. Bekes -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben@REDACTED Tue Feb 10 20:35:31 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Tue, 10 Feb 2015 20:35:31 +0100 Subject: [erlang-questions] exception error: an error occurred when evaluating an arithmetic expression Message-ID: <54DA5D83.4080609@home.nl> Hello, I have this code : -module(side-effects). -export([display/1]). display(Number) when Number > 0 -> display_acc(Number,[]). display_acc(0,Acc) -> io:format("Number:~p~n",Acc); display_acc(Number, Acc) -> display_acc(Number -1, [Number | Acc]). but as soon as I compile it, I see this message : ** exception error: an error occurred when evaluating an arithmetic expression in operator -/2 called as side - effects What does that error exactly mean and how can I solve the code so I can make it work ? Roelof From rpettit@REDACTED Tue Feb 10 20:36:54 2015 From: rpettit@REDACTED (Rick Pettit) Date: Tue, 10 Feb 2015 13:36:54 -0600 Subject: [erlang-questions] exception error: an error occurred when evaluating an arithmetic expression In-Reply-To: <54DA5D83.4080609@home.nl> References: <54DA5D83.4080609@home.nl> Message-ID: <259A781C-3A98-4E64-A771-26DBAF975C48@vailsys.com> You can try giving your module a legal name (i.e. try replacing the minus ?-? with an underscore ?_?). -Rick > On Feb 10, 2015, at 1:35 PM, Roelof Wobben wrote: > > Hello, > > I have this code : > > -module(side-effects). > > -export([display/1]). > > display(Number) when Number > 0 -> > display_acc(Number,[]). > > display_acc(0,Acc) -> > io:format("Number:~p~n",Acc); > > display_acc(Number, Acc) -> > display_acc(Number -1, [Number | Acc]). > > but as soon as I compile it, I see this message : > > ** exception error: an error occurred when evaluating an arithmetic expression > in operator -/2 > called as side - effects > > > What does that error exactly mean and how can I solve the code so I can make it work ? > > Roelof > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From rpettit@REDACTED Tue Feb 10 20:37:37 2015 From: rpettit@REDACTED (Rick Pettit) Date: Tue, 10 Feb 2015 13:37:37 -0600 Subject: [erlang-questions] exception error: an error occurred when evaluating an arithmetic expression In-Reply-To: <259A781C-3A98-4E64-A771-26DBAF975C48@vailsys.com> References: <54DA5D83.4080609@home.nl> <259A781C-3A98-4E64-A771-26DBAF975C48@vailsys.com> Message-ID: Naturally you?ll need to rename the file accordingly as well :-) -Rick > On Feb 10, 2015, at 1:36 PM, Rick Pettit wrote: > > You can try giving your module a legal name (i.e. try replacing the minus ?-? with an underscore ?_?). > > -Rick > >> On Feb 10, 2015, at 1:35 PM, Roelof Wobben wrote: >> >> Hello, >> >> I have this code : >> >> -module(side-effects). >> >> -export([display/1]). >> >> display(Number) when Number > 0 -> >> display_acc(Number,[]). >> >> display_acc(0,Acc) -> >> io:format("Number:~p~n",Acc); >> >> display_acc(Number, Acc) -> >> display_acc(Number -1, [Number | Acc]). >> >> but as soon as I compile it, I see this message : >> >> ** exception error: an error occurred when evaluating an arithmetic expression >> in operator -/2 >> called as side - effects >> >> >> What does that error exactly mean and how can I solve the code so I can make it work ? >> >> Roelof >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > From r.wobben@REDACTED Tue Feb 10 21:56:03 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Tue, 10 Feb 2015 21:56:03 +0100 Subject: [erlang-questions] exception error: an error occurred when evaluating an arithmetic expression In-Reply-To: References: <54DA5D83.4080609@home.nl> <259A781C-3A98-4E64-A771-26DBAF975C48@vailsys.com> Message-ID: <54DA7063.1030204@home.nl> Thanks, Now I can work on the other errors. Roelof Rick Pettit schreef op 10-2-2015 om 20:37: > Naturally you?ll need to rename the file accordingly as well :-) > > -Rick > >> On Feb 10, 2015, at 1:36 PM, Rick Pettit wrote: >> >> You can try giving your module a legal name (i.e. try replacing the minus ?-? with an underscore ?_?). >> >> -Rick >> >>> On Feb 10, 2015, at 1:35 PM, Roelof Wobben wrote: >>> >>> Hello, >>> >>> I have this code : >>> >>> -module(side-effects). >>> >>> -export([display/1]). >>> >>> display(Number) when Number > 0 -> >>> display_acc(Number,[]). >>> >>> display_acc(0,Acc) -> >>> io:format("Number:~p~n",Acc); >>> >>> display_acc(Number, Acc) -> >>> display_acc(Number -1, [Number | Acc]). >>> >>> but as soon as I compile it, I see this message : >>> >>> ** exception error: an error occurred when evaluating an arithmetic expression >>> in operator -/2 >>> called as side - effects >>> >>> >>> What does that error exactly mean and how can I solve the code so I can make it work ? >>> >>> Roelof >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions > From martink@REDACTED Tue Feb 10 21:57:34 2015 From: martink@REDACTED (Martin Karlsson) Date: Wed, 11 Feb 2015 09:57:34 +1300 Subject: [erlang-questions] Mnesia create tables best practices In-Reply-To: References: <87467EDF-C075-4F77-8993-C4108D2432A6@widetag.com> Message-ID: Hi Jesper, This is an interesting approach. I've gone the " leads to misery" path :) I.e when a node starts up if it doesn't have a schema it waits for an initialisation command from the use and it can either initialise itself as the first node in the cluster or join another node. I've never been fully happy with this. How would your approach work with multiple nodes? I can understand starting the first node using a pre-initialised schema but then the other node starts up you want it to be able to join the mnesia cluster in a nice way and not start and initialise its own schema. An alternative I've also seen is having an mnesia "install" phase and use the erlang boot scripts to kick the install process off. Cheers, Martin On 11 February 2015 at 02:20, Jesper Louis Andersen < jesper.louis.andersen@REDACTED> wrote: > > On Sun, Feb 8, 2015 at 7:25 PM, Roberto Ostinelli < > roberto.ostinelli@REDACTED> wrote: > >> Can you please expand on this? Do you mean that when you boot a system >> you reset the db? > > > The DB is never reset. It is just that on the first deploy, there is a > valid DB the system can use to start up and get to work. Apart from having > the right schema, it can also be pre-populated with important data the > systems needs in order to function correctly. > > > > > -- > J. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Feb 11 02:52:02 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 11 Feb 2015 14:52:02 +1300 Subject: [erlang-questions] head mismatch In-Reply-To: <54D9BD61.1000005@home.nl> References: <54D9BAED.8050406@home.nl> <54D9BC1D.7060800@ericsson.com> <54D9BD61.1000005@home.nl> Message-ID: <65617A9E-EF30-4961-BA47-B1249F6BD85C@cs.otago.ac.nz> I suppose I should point out sum(N) when is_integer(N), N >= 0 -> sum(0, N). sum(L, U) when is_integer(L), is_integer(U), U >= L-> (U+L)*(U-L+1)//2. I should also point out that I don't find "sum_acc" an intention-revealing name. >>> >>> Am I not alllowed to do this >>> >>> sum(x) -> >>> x ; >>> >>> sum(x,y) -> >>> x + y. >>> >>> or is there something else missing ? Can I suggest a strategy for dealing with such questions? Try it. -main(q1). -export([sum/1,sum/2]). sum(X) -> X; % is this OK? sum(X, Y) -> X+Y. Compile it. The compiler _will_ complain. It will be the same "head mismatch" error you saw. The compiler could be more helpful. Instead of saying "head mismatch", it could say "Error: function sum/1 is followed by a clause for sum/2 but there is no full stop at the end of sum/1." From ok@REDACTED Wed Feb 11 03:56:31 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 11 Feb 2015 15:56:31 +1300 Subject: [erlang-questions] output [[[[]|2]|1]|0] instead of [2.1.0] In-Reply-To: <54DA1381.8030605@home.nl> References: <54DA1381.8030605@home.nl> Message-ID: <6E81C0F3-177A-47E3-9CDB-88F9DAACD15E@cs.otago.ac.nz> On 11/02/2015, at 3:19 am, Roelof Wobben wrote: > Hello, > > I have to make a reversed list to a number so reverse_list(2) will output [2.1] Why should an integer 2 yield a floating point 2.1? > > I have this code : > > -module(list_creation). You are still trying to think in imperative, possibly object-oriented terms. There is no creation here. > > -export([create/1, create_reverse/1]). These are bad names. Create (what does that mean?) WHAT? I think you want something like ascending_counts(2) -> [0,1,2] descending_counts(2) -> [2,1,0] > > create(Number) when Number >= 0 -> > create_acc(Number,[]). I find the suffix "_acc" totally unhelpful. What is an acc? Or what is accing? What does it mean to create an acc? descending_counts(N) when is_integer(N), N >= 0 -> [N | descending_counts(N - 1)]; descending_counts(N) when is_integer(N), N < 0 -> []. ascending_counts(N) when is_integer(N), N >= 0 -> ascending_counts_loop(N, []). ascending_counts_loop(N, Counts) when N >= 0 -> ascending_counts_loop(N - 1, [N|Counts]); ascending_counts_loop(N, Counts) when N < 0 -> Counts. > > but when I do create_reverse(2) I see this output [[[[]|2]|1]|0] instead of [2,1,0] > > Does the ++ always produce this when adding a item to a list ? ++ DOES NOT ADD AN ITEM TO A LIST. ++ *concatenates* TWO lists. Again, what you should do is TRY IT. % erl 1> Acc = []. [] 2> [Acc] ++ 1. [[]|1]. Presumably what you mean is 3> Acc ++ [1]. [1] From ok@REDACTED Wed Feb 11 04:39:02 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 11 Feb 2015 16:39:02 +1300 Subject: [erlang-questions] exception error: an error occurred when evaluating an arithmetic expression In-Reply-To: <54DA5D83.4080609@home.nl> References: <54DA5D83.4080609@home.nl> Message-ID: <03579688-ECF2-417A-945F-2DF6CA13DCF6@cs.otago.ac.nz> On 11/02/2015, at 8:35 am, Roelof Wobben wrote: > Hello, > > I have this code : > > -module(side-effects). > > -export([display/1]). > > display(Number) when Number > 0 -> > display_acc(Number,[]). > > display_acc(0,Acc) -> > io:format("Number:~p~n",Acc); > > display_acc(Number, Acc) -> > display_acc(Number -1, [Number | Acc]). > > but as soon as I compile it, I see this message : > > ** exception error: an error occurred when evaluating an arithmetic expression > in operator -/2 > called as side - effects > > > What does that error exactly mean and how can I solve the code so I can make it work ? The system told you exactly what happened. For some reason, the compiler tried to evaluate side - effects. Where is that in your code? Oh ho! You called your module side-effects with a hyphen/minus instead of side_effects with an underscore. I don't even want to try to imagine why the compiler might try to evaluate the module name as an expression. > From jim.rosenblum@REDACTED Wed Feb 11 04:40:37 2015 From: jim.rosenblum@REDACTED (jim rosenblum) Date: Tue, 10 Feb 2015 22:40:37 -0500 Subject: [erlang-questions] snmpm:register_agent/3 suddenly stopped working! Message-ID: Folks, I have an application that uses snmp that used to work and all of a sudden doesn't - I did upgrade from 17.1 to 17.4 - but other than that nothing has changed that I know of. I am having trouble down-grading, so I cannot confirm that the upgrade is the culprit. When I do the following from a machine with IP address 10.6.81.19 1> snmpm:register_agent(hope,"Hope", [{engine_id, "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"}]). I get {error,{bad_address,{snmpUDPDomain,"10.7.42.11"}}} I have an appropriate snmpd.conf on 10.7.42.11 that has com2sec sentrysrv 10.6.81.19/32 CLSENTRY group CLROGroup v2c sentrysrv view all included .1 80 access CLROGroup "" v2c noauth exact all none none adding {tdomain, transportDomainUdpIpv4} to the option list results in the, essentially, same error: {error,{bad_address,{{error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} Both machines can ping each other. The snmpd daemon is running on .11, I have tried all kinds of additional options (port, etc.), but cannot get it to work This is *killing* me, can anyone point out what stupid thing I am doing wrong? -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Feb 11 05:26:47 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 11 Feb 2015 17:26:47 +1300 Subject: [erlang-questions] is this a well written function In-Reply-To: <54D88028.8000802@home.nl> References: <54D88028.8000802@home.nl> Message-ID: On 9/02/2015, at 10:38 pm, Roelof Wobben wrote: > Hello, > > I tried to solve the exercise where I have to calculate the outcome of 1 ... n The outcome of doing what? So I have this : > > -module(sum_recursion). This is a poor name. From the outside, you cannot tell how the sum is computed, and you probably should not care. If you are doing exercises from a book, it is better to name your modules for the exercises, e.g. chapter_2_exercise_4. > > -export([sum/1]). > > % when the number is zero the outcome will also be zero > sum(0) -> > 0; > > % when the output is a number higher then 0 , the acc function will be called. > sum(Number) -> sum_acc(Number, 0, 0 ). Your comments must be (1) true (2) useful. Ad (1), there is no 'acc' function, so the comment is untrue. Ad (2), the comment is not USEFUL. What you are missing is a comment that says WHAT THE FUNCTION IS ABOUT. Something like %% sum(N) answers 1+2+...+N when N is a non-negative integer. %% It is not defined for other arguments. %% The implementation uses tail recursion, where the %% control argument counts up from 0 to N and the %% accumulator argument holds the running prefix of the sum. These observations on comments have nothing to do with Erlang. No matter what programming language you are using, your comments should be true, useful, and not just paraphrase the code. > > % when the numbers are equal then the end is reached and the last item is added to the acc variable, > % the acc variable hold the value of the sum as it is calculated This comment is not good. You have *three* numbers. Which two of them are supposed to be equal? The phrase "junk comment" is generally used for comments that simply paraphrase the code. In Erlang, you CANNOT "add to the acc variable" (which is Acc, not acc). Once an Erlang variable has a value, that is its value for as long as it exists. Good code for this might be sum(N) when is_integer(N), N >= 0 -> (N * (N+1)) // 2. From jim.rosenblum@REDACTED Wed Feb 11 05:31:56 2015 From: jim.rosenblum@REDACTED (jim rosenblum) Date: Tue, 10 Feb 2015 23:31:56 -0500 Subject: [erlang-questions] More Information: snmpm:register_agent/3 suddenly stopped working! Message-ID: More information: on 17.4 CentOS release 5.5 -- used to work before I upgraded from 17.1 > snmpm:register_agent(snmp_manager,"Hope", [{engine_id, "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"},{port,161}, {tdomain,transportDomainUdpIpv4},{sec_level, noAuthNoPriv},{sec_name, "initial"},{version, v2},{timeout,1000}]). > ok on 17.1 CentOS release 6.2 snmpm:register_agent(snmp_manager,"Hope", [{engine_id, "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"},{port,161}, {tdomain,transportDomainUdpIpv4},{sec_level, noAuthNoPriv},{sec_name, "initial"},{version, v2},{timeout,1000}]). {error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} On Tue, Feb 10, 2015 at 10:40 PM, jim rosenblum wrote: > Folks, > > I have an application that uses snmp that used to work and all of a sudden > doesn't - I did upgrade from 17.1 to 17.4 - but other than that nothing has > changed that I know of. I am having trouble down-grading, so I cannot > confirm that the upgrade is the culprit. > > When I do the following from a machine with IP address 10.6.81.19 > 1> snmpm:register_agent(hope,"Hope", [{engine_id, > "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"}]). > > I get > {error,{bad_address,{snmpUDPDomain,"10.7.42.11"}}} > > I have an appropriate snmpd.conf on 10.7.42.11 that has > > com2sec sentrysrv 10.6.81.19/32 CLSENTRY > group CLROGroup v2c sentrysrv > view all included .1 80 > access CLROGroup "" v2c noauth exact all none none > > adding {tdomain, transportDomainUdpIpv4} to the option list results in > the, essentially, same error: > > {error,{bad_address,{{error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} > > > Both machines can ping each other. The snmpd daemon is running on .11, I > have tried all kinds of additional options (port, etc.), but cannot get it > to work > > This is *killing* me, can anyone point out what stupid thing I am doing > wrong? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim.rosenblum@REDACTED Wed Feb 11 05:36:43 2015 From: jim.rosenblum@REDACTED (jim rosenblum) Date: Tue, 10 Feb 2015 23:36:43 -0500 Subject: [erlang-questions] More Information: snmpm:register_agent/3 suddenly stopped working! Message-ID: Sorry, I said it backwards in my last email. It works on 17.1 does not work on 17.4. More information: on 17.1 CentOS release 6.2 > snmpm:register_agent(snmp_manager,"Hope", [{engine_id, "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"},{port,161}, {tdomain,transportDomainUdpIpv4},{sec_level, noAuthNoPriv},{sec_name, "initial"},{version, v2},{timeout,1000}]). > ok on 17.4 CentOS release 5.5 -- used to work before I upgraded to 17.4 snmpm:register_agent(snmp_manager,"Hope", [{engine_id, "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"},{port,161}, {tdomain,transportDomainUdpIpv4},{sec_level, noAuthNoPriv},{sec_name, "initial"},{version, v2},{timeout,1000}]). {error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} On Tue, Feb 10, 2015 at 10:40 PM, jim rosenblum > wrote: > >> Folks, >> >> I have an application that uses snmp that used to work and all of a >> sudden doesn't - I did upgrade from 17.1 to 17.4 - but other than that >> nothing has changed that I know of. I am having trouble down-grading, so I >> cannot confirm that the upgrade is the culprit. >> >> When I do the following from a machine with IP address 10.6.81.19 >> 1> snmpm:register_agent(hope,"Hope", [{engine_id, >> "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"}]). >> >> I get >> {error,{bad_address,{snmpUDPDomain,"10.7.42.11"}}} >> >> I have an appropriate snmpd.conf on 10.7.42.11 that has >> >> com2sec sentrysrv 10.6.81.19/32 CLSENTRY >> group CLROGroup v2c sentrysrv >> view all included .1 80 >> access CLROGroup "" v2c noauth exact all none none >> >> adding {tdomain, transportDomainUdpIpv4} to the option list results in >> the, essentially, same error: >> >> {error,{bad_address,{{error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} >> >> >> Both machines can ping each other. The snmpd daemon is running on .11, I >> have tried all kinds of additional options (port, etc.), but cannot get it >> to work >> >> This is *killing* me, can anyone point out what stupid thing I am doing >> wrong? >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From 459673409@REDACTED Wed Feb 11 07:16:46 2015 From: 459673409@REDACTED (=?utf-8?B?5pat6IiN56a7?=) Date: Wed, 11 Feb 2015 14:16:46 +0800 Subject: [erlang-questions] It seems that eunit tests run twice, someone happens to encounter this ??? Message-ID: Hi, It seems that the eunit tests have been run twice. The code comes from my company's project,so i can not paste all concerned code here,and i just want to know that does someone once has such problems before?Just tell me how to fix the bug when you meet the similar problems,maybe i can get some guides from your suituation. Thanks!:) I search the google,and find some: http://lists.basho.com/pipermail/rebar_lists.basho.com/2010-July/000144.html? But i still can not figur out why,Please help me Sorry for my poor English Best regard! ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From mrtndimitrov@REDACTED Wed Feb 11 08:11:20 2015 From: mrtndimitrov@REDACTED (Martin Koroudjiev) Date: Wed, 11 Feb 2015 09:11:20 +0200 Subject: [erlang-questions] is this a well written function In-Reply-To: References: <54D88028.8000802@home.nl> Message-ID: <54DB0098.8000702@gmail.com> > sum(N) when is_integer(N), N >= 0 -> > (N * (N+1)) // 2. > Should be with a single forward slash. Also the OP should know that this function will return a float. From r.wobben@REDACTED Wed Feb 11 08:45:33 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Wed, 11 Feb 2015 08:45:33 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: References: <54D88028.8000802@home.nl> Message-ID: <54DB089D.50900@home.nl> Richard A. O'Keefe schreef op 11-2-2015 om 5:26: > On 9/02/2015, at 10:38 pm, Roelof Wobben wrote: > >> Hello, >> >> I tried to solve the exercise where I have to calculate the outcome of 1 ... n > The outcome of doing what? > > So I have this : >> -module(sum_recursion). > This is a poor name. From the outside, you cannot tell how the sum is > computed, and you probably should not care. If you are doing exercises > from a book, it is better to name your modules for the exercises, > e.g. chapter_2_exercise_4. >> -export([sum/1]). >> >> % when the number is zero the outcome will also be zero >> sum(0) -> >> 0; >> >> % when the output is a number higher then 0 , the acc function will be called. >> sum(Number) -> sum_acc(Number, 0, 0 ). > Your comments must be > (1) true > (2) useful. > > Ad (1), there is no 'acc' function, so the comment is untrue. > Ad (2), the comment is not USEFUL. > > What you are missing is a comment that says WHAT THE FUNCTION IS ABOUT. > Something like > > %% sum(N) answers 1+2+...+N when N is a non-negative integer. > %% It is not defined for other arguments. > %% The implementation uses tail recursion, where the > %% control argument counts up from 0 to N and the > %% accumulator argument holds the running prefix of the sum. > > These observations on comments have nothing to do with Erlang. > No matter what programming language you are using, your comments > should be true, useful, and not just paraphrase the code. > >> % when the numbers are equal then the end is reached and the last item is added to the acc variable, >> % the acc variable hold the value of the sum as it is calculated > This comment is not good. You have *three* numbers. Which two of them are supposed to be > equal? The phrase "junk comment" is generally used for comments that simply paraphrase the > code. > > In Erlang, you CANNOT "add to the acc variable" (which is Acc, not acc). > Once an Erlang variable has a value, that is its value for as long as it exists. > > Good code for this might be > > sum(N) when is_integer(N), N >= 0 -> > (N * (N+1)) // 2. > > Thanks for all the remarks. I use recursion because the exercises from the Erlang programming book asked me to use it. Here another try from another exercise from that book. -module(side_effects). -export([display_numbers/1]). %% displays(N) displays the numbers from 1,2,...+N when N is a non-negative integer. %% It is not defined for other arguments. %% When N is a non-negative number, a helper function is called so it prints out %% the numbers in the right order. This is a exercise from the Erlang Programming book %% where I have to practice side-effects. display_numbers(Number) when Number > 0 -> display_numbers_loop(Number, 1). %% When the control argument)(second argument) is equal to the number %% the user has given, the end is reached and the last number is printed display_numbers_loop(Number, Number) -> io:format("Number:~p~n",[Number]); %% When the contro argument(second argument) is not equal to the number %5 the user has given the control argument is increased by one and the %% display_numbers_loop function is called again with the new arguments. display_numbers_loop(Number, Current) -> io:format("Number:~p~n",[Current]), display_numbers_loop(Number, Current +1 ). Roelof From roberto.ostinelli@REDACTED Wed Feb 11 09:07:44 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Wed, 11 Feb 2015 09:07:44 +0100 Subject: [erlang-questions] Mnesia create tables best practices In-Reply-To: References: <87467EDF-C075-4F77-8993-C4108D2432A6@widetag.com> Message-ID: <7A8865DD-DD04-4637-B965-85CD9014873E@widetag.com> Adding to this: doesn't it mean that the name and full host of the node need to be known before you can initialize your db, hence a release can only be specific for a specific full node name? > On 10/feb/2015, at 21:57, Martin Karlsson wrote: > > Hi Jesper, > > This is an interesting approach. I've gone the " leads to misery" path :) I.e when a node starts up if it doesn't have a schema it waits for an initialisation command from the use and it can either initialise itself as the first node in the cluster or join another node. I've never been fully happy with this. > > How would your approach work with multiple nodes? I can understand starting the first node using a pre-initialised schema but then the other node starts up you want it to be able to join the mnesia cluster in a nice way and not start and initialise its own schema. > > An alternative I've also seen is having an mnesia "install" phase and use the erlang boot scripts to kick the install process off. > > Cheers, > Martin > > > >> On 11 February 2015 at 02:20, Jesper Louis Andersen wrote: >> >>> On Sun, Feb 8, 2015 at 7:25 PM, Roberto Ostinelli wrote: >>> Can you please expand on this? Do you mean that when you boot a system you reset the db? >> >> The DB is never reset. It is just that on the first deploy, there is a valid DB the system can use to start up and get to work. Apart from having the right schema, it can also be pre-populated with important data the systems needs in order to function correctly. >> >> >> >> >> -- >> J. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominik_pawlak@REDACTED Wed Feb 11 09:33:42 2015 From: dominik_pawlak@REDACTED (Dominik Pawlak) Date: Wed, 11 Feb 2015 09:33:42 +0100 Subject: [erlang-questions] More Information: snmpm:register_agent/3 suddenly stopped working! In-Reply-To: References: Message-ID: <54DB13E6.1070908@yahoo.co.uk> Hello Jim, snmp application has changed between 17.1 (snmp v4.25.1) and 17.4 (snmp v5.1.1). According to docs the address should look like: "Addr is the address in the transport domain, either an {IpAddr, IpPort} tuple or a traditional SNMP integer list containing port number. IpAddr is either a regular Erlang/OTP ip_address() or a traditional SNMP integer list not containing port number, and IpPort is an integer. ip_address() = ip4_address() | ip6_address() ip4_address() = {0..255, 0..255, 0..255, 0..255}" I always used [127,0,0,1] or {127,0,0,1} and never had any problem with it, I have never tried with "127.0.0.1". Best Dominik On 11.02.2015 05:31, jim rosenblum wrote: > More information: > > on 17.4 CentOS release 5.5 -- used to work before I upgraded from 17.1 > > snmpm:register_agent(snmp_manager,"Hope", [{engine_id, > "mgrEngine"},{community,"CLSENTRY"},{address, > "10.7.42.11"},{port,161}, {tdomain,transportDomainUdpIpv4},{sec_level, > noAuthNoPriv},{sec_name, "initial"},{version, v2},{timeout,1000}]). > > ok > > > on 17.1 CentOS release 6.2 > snmpm:register_agent(snmp_manager,"Hope", [{engine_id, > "mgrEngine"},{community,"CLSENTRY"},{address, > "10.7.42.11"},{port,161}, {tdomain,transportDomainUdpIpv4},{sec_level, > noAuthNoPriv},{sec_name, "initial"},{version, v2},{timeout,1000}]). > > {error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} > > > > On Tue, Feb 10, 2015 at 10:40 PM, jim rosenblum > > wrote: > > Folks, > > I have an application that uses snmp that used to work and all of > a sudden doesn't - I did upgrade from 17.1 to 17.4 - but other > than that nothing has changed that I know of. I am having trouble > down-grading, so I cannot confirm that the upgrade is the culprit. > > When I do the following from a machine with IP address 10.6.81.19 > 1> snmpm:register_agent(hope,"Hope", [{engine_id, > "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"}]). > > I get > {error,{bad_address,{snmpUDPDomain,"10.7.42.11"}}} > > I have an appropriate snmpd.conf on 10.7.42.11 that has > > com2sec sentrysrv 10.6.81.19/32 CLSENTRY > group CLROGroup v2c sentrysrv > view all included .1 80 > access CLROGroup "" v2c noauth exact all none none > > adding {tdomain, transportDomainUdpIpv4} to the option list > results in the, essentially, same error: > {error,{bad_address,{{error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} > > > Both machines can ping each other. The snmpd daemon is running on > .11, I have tried all kinds of additional options (port, etc.), > but cannot get it to work > > This is *killing* me, can anyone point out what stupid thing I am > doing wrong? > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From seand-erlang@REDACTED Wed Feb 11 12:38:46 2015 From: seand-erlang@REDACTED (SeanD) Date: Wed, 11 Feb 2015 11:38:46 +0000 Subject: [erlang-questions] SSL performance Message-ID: Hi, We are experiencing a bottleneck in our application that has the option of using SSL. Conducting some generic tests, I am seeing that SSL can be upto 20,000 times slower when processing large amounts of data and was wondering if anyone else has seen the same behaviour or can tell me that I'm doing something really silly? Transferring a 200MB binary between 2 nodes on the same machine using gen_tcp is taking between 100 and 200 microseconds, whilst transferring the same binary using ssl usually takes around 3 seconds! I'm currently using R16B01, but can happily move to a later version if this is required. Is there any way to speed this up or any alternative SSL implementations that call out to openssl natively that could be used instead? Any insights would be very welcome. Thanks, Sean P.S. The code I'm using is enclosed below: -module(network_performance). -export([client/0,ssl_client/0,server/1,ssl_server/1]). client() -> SomeHostInNet = "localhost", % to make it runnable on one machine {ok, Sock} = gen_tcp:connect(SomeHostInNet, 5678, [binary, {packet, 0}, {active, once}]), Before = erlang:now(), ok = do_client_recv(Sock), After = erlang:now(), ok = gen_tcp:close(Sock), io:format("Time taken: ~p microsecs~n",[total_microsecs(After) - total_microsecs(Before)]). server(Data) -> {ok, LSock} = gen_tcp:listen(5678, [binary, {packet, raw}, {active, once},{reuseaddr,true}]), {ok, Sock} = gen_tcp:accept(LSock), gen_tcp:send(Sock, Data), gen_tcp:close(Sock). ssl_client() -> SomeHostInNet = "localhost", % to make it runnable on one machine ssl:start(), {ok, Sock} = ssl:connect(SomeHostInNet, 5679, [binary, {packet, 0}, {active, once}]), ok = ssl:ssl_accept(Sock), Before = erlang:now(), ok = do_client_recv(Sock), After = erlang:now(), ok = ssl:close(Sock), io:format("Time taken: ~p microsecs~n",[total_microsecs(After) - total_microsecs(Before)]). ssl_server(Data) -> ssl:start(), {ok, LSock} = ssl:listen(5679, [binary, {packet, raw}, {active, once},{reuseaddr,true},{certfile,"test.pem"},{keyfile,"test.key"}]), {ok, Sock} = ssl:transport_accept(LSock), ok = ssl:ssl_accept(Sock), ssl:send(Sock, Data), ssl:close(Sock). total_microsecs({MegaSecs,Secs,MicroSecs}) -> (MegaSecs*1000000 + Secs)*1000000 + MicroSecs. do_client_recv(Socket) -> receive {tcp, Socket, _Data} -> ok; {ssl, Socket, _Data} -> ok; {tcp_closed, Socket} -> io:format("Socket closed~n",[]); {tcp_error, Socket, Reason} -> io:format("Error: ~p~n",[Reason]) after 20000 -> io:format("Receive timed out~n",[]) end. -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael.s.klishin@REDACTED Wed Feb 11 13:03:28 2015 From: michael.s.klishin@REDACTED (Michael Klishin) Date: Wed, 11 Feb 2015 15:03:28 +0300 Subject: [erlang-questions] SSL performance In-Reply-To: References: Message-ID: On 11 February 2015 at 14:39:00, SeanD (seand-erlang@REDACTED) wrote: > We are experiencing a bottleneck in our application that has > the option of using SSL. Conducting some generic tests, I am seeing > that SSL can be upto 20,000 times slower when processing large > amounts of data and was wondering if anyone else has seen the same > behaviour or can tell me that I'm doing something really silly? > > Transferring a 200MB binary between 2 nodes on the same machine > using gen_tcp is taking between 100 and 200 microseconds, whilst > transferring the same binary using ssl usually takes around > 3 seconds! I'm currently using R16B01, but can happily move to > a later version if this is required. How many iterations do you run? You seem to be opening a new connection per iteration, the result then is going to be pretty different from opening just one connection and performing N iterations over it.? TLS upgrade at connection stage takes more time but data transfer throughput should be comparable. -- @michaelklishin, github.com/michaelklishin From jon@REDACTED Wed Feb 11 13:04:21 2015 From: jon@REDACTED (Jon Schneider) Date: Wed, 11 Feb 2015 12:04:21 -0000 Subject: [erlang-questions] SSL performance In-Reply-To: References: Message-ID: <338df60e5d7165f53c977e7d43583663.squirrel@mail.jschneider.net> Of the order of a hundred megabytes a second is indeed what you might get with various crypto operations on a modernish processor (which of course do have some instructions that help). But to be sure you need to find out what algorithm is used beyond key exchange. You can then run something like "openssl speed". Then consider whether this really needs securing and if so could you use a lighter algorithm. I assume you don't really have a need to transfer data securely across processes on the same machine. That would be silly and better done using common OS security (if only nodes could connect via UNIX domain sockets). Otherwise you still have Gigabit ethernet speed. So what is the problem again ? Jon From roger@REDACTED Wed Feb 11 13:22:20 2015 From: roger@REDACTED (Roger Lipscombe) Date: Wed, 11 Feb 2015 12:22:20 +0000 Subject: [erlang-questions] It seems that eunit tests run twice, someone happens to encounter this ??? In-Reply-To: References: Message-ID: If you have: all_test_() -> [a_test, b_test]. a_test() -> ?assert(true). b_test() -> ?assert(true). Then they get run twice, once as part of the fixture, and again because they've got names ending in '_test'. Is this what you're seeing? On 11 February 2015 at 06:16, ??? <459673409@REDACTED> wrote: > Hi, > It seems that the eunit tests have been run twice. > The code comes from my company's project,so i can not paste all concerned > code here,and i just want to know that does someone once has such problems > before?Just tell me how to fix the bug when you meet the similar > problems,maybe i can get some guides from your suituation. > Thanks!:) > I search the google,and find some: > > http://lists.basho.com/pipermail/rebar_lists.basho.com/2010-July/000144.html? > > But i still can not figur out why,Please help me > Sorry for my poor English > Best regard! > ? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From seriy.pr@REDACTED Wed Feb 11 13:24:40 2015 From: seriy.pr@REDACTED (=?UTF-8?B?0KHQtdGA0LPQtdC5INCf0YDQvtGF0L7RgNC+0LI=?=) Date: Wed, 11 Feb 2015 15:24:40 +0300 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online Message-ID: I'm glad to announce a service, which allow to run arbitrary Erlang code from your browser. For now it is there: http://tryerl.seriyps.ru/ How it works Each request is handled by Cowboy web server, which launches new Erlang VM instance per request inside lightweight linux container, based on https://github.com/thestinger/playpen. There are restrictions on networking, memory and execution time, but nothing else. What does it have As you already heard, there is erlang code evaluation, but also compilation to several intermediate formats, like core erlang, macros expanding, beam and erlang assemblers and so on. And all this can be launched under any erlang release version (for now it's only the latter 8, but I can add more by demand). Of course, there is 'pastebin' functionality, so you can save and share snippet with somebody else. Possible use-cases: * Explore code compatibility with all Erlang releases * Share runnable erlang snippet with somebody * Try to launch some dangerous code * Quickly explore how your code is compiled to erlang asm instructions * Maybe, for some online studying / webinars. Students are don't even need to install erlang on their computers * In blog posts / articles / documentation - to make code snippets more interactive Idea was borrowed from https://play.rust-lang.org/. P.S.: it will be great, if you suggest some funny / interesting code snippets for ?Examples? section. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivan@REDACTED Wed Feb 11 13:29:43 2015 From: ivan@REDACTED (Ivan Uemlianin) Date: Wed, 11 Feb 2015 12:29:43 +0000 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: <54DB4B37.5090401@llaisdy.com> The different compilation options are especially nice! Thanks! Ivan On 11/02/2015 12:24, ?????? ???????? wrote: > I'm glad to announce a service, which allow to run arbitrary Erlang > code from your browser. For now it is there: > > http://tryerl.seriyps.ru/ > > How it works > Each request is handled by Cowboy web server, which launches new > Erlang VM instance per request inside lightweight linux container, > based on https://github.com/thestinger/playpen. There are restrictions > on networking, memory and execution time, but nothing else. > > What does it have > As you already heard, there is erlang code evaluation, but also > compilation to several intermediate formats, like core erlang, macros > expanding, beam and erlang assemblers and so on. And all this can be > launched under any erlang release version (for now it's only the > latter 8, but I can add more by demand). > Of course, there is 'pastebin' functionality, so you can save and > share snippet with somebody else. > > Possible use-cases: > * Explore code compatibility with all Erlang releases > * Share runnable erlang snippet with somebody > * Try to launch some dangerous code > * Quickly explore how your code is compiled to erlang asm instructions > * Maybe, for some online studying / webinars. Students are don't even > need to install erlang on their computers > * In blog posts / articles / documentation - to make code snippets > more interactive > > Idea was borrowed from https://play.rust-lang.org/. > > P.S.: it will be great, if you suggest some funny / interesting code > snippets for ?Examples? section. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- ============================================================ Ivan A. Uemlianin PhD Llaisdy Speech Technology Research and Development ivan@REDACTED @llaisdy llaisdy.wordpress.com github.com/llaisdy www.linkedin.com/in/ivanuemlianin festina lente ============================================================ -------------- next part -------------- An HTML attachment was scrubbed... URL: From prof3ta@REDACTED Wed Feb 11 13:50:27 2015 From: prof3ta@REDACTED (Roberto Aloi) Date: Wed, 11 Feb 2015 13:50:27 +0100 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: Awesome stuff. I would consider migrating the tryerlang.org tutorials to your sandbox, to remove many of its current limitations. Is command evaluation available through an API? On 11 February 2015 at 13:24, ?????? ???????? wrote: > I'm glad to announce a service, which allow to run arbitrary Erlang code > from your browser. For now it is there: > > http://tryerl.seriyps.ru/ > > How it works > Each request is handled by Cowboy web server, which launches new Erlang VM > instance per request inside lightweight linux container, based on > https://github.com/thestinger/playpen. There are restrictions on > networking, memory and execution time, but nothing else. > > What does it have > As you already heard, there is erlang code evaluation, but also > compilation to several intermediate formats, like core erlang, macros > expanding, beam and erlang assemblers and so on. And all this can be > launched under any erlang release version (for now it's only the latter 8, > but I can add more by demand). > Of course, there is 'pastebin' functionality, so you can save and share > snippet with somebody else. > > Possible use-cases: > * Explore code compatibility with all Erlang releases > * Share runnable erlang snippet with somebody > * Try to launch some dangerous code > * Quickly explore how your code is compiled to erlang asm instructions > * Maybe, for some online studying / webinars. Students are don't even need > to install erlang on their computers > * In blog posts / articles / documentation - to make code snippets more > interactive > > Idea was borrowed from https://play.rust-lang.org/. > > P.S.: it will be great, if you suggest some funny / interesting code > snippets for ?Examples? section. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Roberto Aloi --- Website: http://roberto-aloi.com Twitter: @robertoaloi -------------- next part -------------- An HTML attachment was scrubbed... URL: From pablo.platt@REDACTED Wed Feb 11 13:53:23 2015 From: pablo.platt@REDACTED (pablo platt) Date: Wed, 11 Feb 2015 14:53:23 +0200 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: How is the playpen sandbox different from docker? I know that docker is not 100% secure but it is very popular so the chance for security holes to be found might be higher. On Wed, Feb 11, 2015 at 2:50 PM, Roberto Aloi wrote: > Awesome stuff. I would consider migrating the tryerlang.org tutorials to > your sandbox, to remove many of its current limitations. > Is command evaluation available through an API? > > > On 11 February 2015 at 13:24, ?????? ???????? wrote: > >> I'm glad to announce a service, which allow to run arbitrary Erlang code >> from your browser. For now it is there: >> >> http://tryerl.seriyps.ru/ >> >> How it works >> Each request is handled by Cowboy web server, which launches new Erlang >> VM instance per request inside lightweight linux container, based on >> https://github.com/thestinger/playpen. There are restrictions on >> networking, memory and execution time, but nothing else. >> >> What does it have >> As you already heard, there is erlang code evaluation, but also >> compilation to several intermediate formats, like core erlang, macros >> expanding, beam and erlang assemblers and so on. And all this can be >> launched under any erlang release version (for now it's only the latter 8, >> but I can add more by demand). >> Of course, there is 'pastebin' functionality, so you can save and share >> snippet with somebody else. >> >> Possible use-cases: >> * Explore code compatibility with all Erlang releases >> * Share runnable erlang snippet with somebody >> * Try to launch some dangerous code >> * Quickly explore how your code is compiled to erlang asm instructions >> * Maybe, for some online studying / webinars. Students are don't even >> need to install erlang on their computers >> * In blog posts / articles / documentation - to make code snippets more >> interactive >> >> Idea was borrowed from https://play.rust-lang.org/. >> >> P.S.: it will be great, if you suggest some funny / interesting code >> snippets for ?Examples? section. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Roberto Aloi > --- > Website: http://roberto-aloi.com > Twitter: @robertoaloi > > _______________________________________________ > 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 Wed Feb 11 13:55:03 2015 From: mononcqc@REDACTED (Fred Hebert) Date: Wed, 11 Feb 2015 07:55:03 -0500 Subject: [erlang-questions] SSL performance In-Reply-To: References: Message-ID: <20150211125500.GC4236@ferdmbp.local> On 02/11, SeanD wrote: > Transferring a 200MB binary between 2 nodes on the same machine using > gen_tcp is taking between 100 and 200 microseconds, whilst transferring the > same binary using ssl usually takes around 3 seconds! I'm currently using > R16B01, but can happily move to a later version if this is required. > Can I ask how you're measuring the time it takes? It sounds like there's plenty of ways to take measurements that will end up giving misleading results. Regards, Fred. From dch@REDACTED Wed Feb 11 13:36:40 2015 From: dch@REDACTED (Dave Cottlehuber) Date: Wed, 11 Feb 2015 13:36:40 +0100 Subject: [erlang-questions] FreeBSD dtrace-enabled builds In-Reply-To: References: Message-ID: <1423658200.3778291.226102697.6175A110@webmail.messagingengine.com> On Sat, 31 Jan 2015, at 10:02 AM, Dave Cottlehuber wrote: > Hi, > > On FreeBSD 10.1R amd64, after building a modified lang/erlang port, the > following alarming warning is displayed. This is the same in the newer > lang/erlang-runtime17 flavour as well BTW. > > WARNING: number of probes fixed does not match the number of defined > probes (1001 != 1088, respectively) > WARNING: some probes might not fire or your program might crash > Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:8:8] [async-threads:64] > [hipe] [kernel-poll:true] [dtrace] > > Eshell V6.3 ?(abort with ^G) > 1> > > No doubt this is in reference the forthcoming zombie apocalypse? > > How serious is this ? does anybody have practical experience to relate? > > Any idea on what the problem might be or what I might need to do to fix > it? > > Assuming this is resolved, what is the practical impact of using a > dtrace-enabled build in production? Is there likely to be a significant > performance hit, or is this even foolish from a stability perspective? > Handwavey answers are entirely appropriate here. > > A+, Dave > ? sent from my Couch Gently bumping this dtrace thread... any takers? Thanks! Dave From dronnikov@REDACTED Wed Feb 11 14:10:48 2015 From: dronnikov@REDACTED (Vladimir Dronnikov) Date: Wed, 11 Feb 2015 16:10:48 +0300 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: ``` % -*- coding: utf8 -*- -module(bomb). -export([loop/0, main/0]). -import(lists, [map/2]). -import(pg2, [pid/0, join/2, get_members/1]). loop() -> join(forks, pid()), receive _ -> spawn(bomb, loop, []), loop() end. main(_) -> spawn(bomb, loop, []), case get_members(forks) of [Pid|Pids] -> map(fun(P) -> P ! 1 end, [Pid|Pids]); _ -> error end, main(1). main() -> main(0). ``` exposes some internal guts to the browser ;) Please check if it's harmless. Good resource. Thank you. --V On Wed, Feb 11, 2015 at 3:24 PM, ?????? ???????? wrote: > I'm glad to announce a service, which allow to run arbitrary Erlang code > from your browser. For now it is there: > > http://tryerl.seriyps.ru/ > > How it works > Each request is handled by Cowboy web server, which launches new Erlang VM > instance per request inside lightweight linux container, based on > https://github.com/thestinger/playpen. There are restrictions on > networking, memory and execution time, but nothing else. > > What does it have > As you already heard, there is erlang code evaluation, but also > compilation to several intermediate formats, like core erlang, macros > expanding, beam and erlang assemblers and so on. And all this can be > launched under any erlang release version (for now it's only the latter 8, > but I can add more by demand). > Of course, there is 'pastebin' functionality, so you can save and share > snippet with somebody else. > > Possible use-cases: > * Explore code compatibility with all Erlang releases > * Share runnable erlang snippet with somebody > * Try to launch some dangerous code > * Quickly explore how your code is compiled to erlang asm instructions > * Maybe, for some online studying / webinars. Students are don't even need > to install erlang on their computers > * In blog posts / articles / documentation - to make code snippets more > interactive > > Idea was borrowed from https://play.rust-lang.org/. > > P.S.: it will be great, if you suggest some funny / interesting code > snippets for <> section. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From askjuise@REDACTED Wed Feb 11 14:13:23 2015 From: askjuise@REDACTED (Alexander Petrovsky) Date: Wed, 11 Feb 2015 13:13:23 +0000 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: Maybe someone will be interesting to see at my version "tryerl" - https://github.com/juise/sherly. I think will be interesting to combine tryerl and sherly, do smth like tryclj.com 2015-02-11 12:53 GMT+00:00 pablo platt : > How is the playpen sandbox different from docker? > I know that docker is not 100% secure but it is very popular so the chance > for security holes to be found might be higher. > > On Wed, Feb 11, 2015 at 2:50 PM, Roberto Aloi wrote: > >> Awesome stuff. I would consider migrating the tryerlang.org tutorials to >> your sandbox, to remove many of its current limitations. >> Is command evaluation available through an API? >> >> >> On 11 February 2015 at 13:24, ?????? ???????? wrote: >> >>> I'm glad to announce a service, which allow to run arbitrary Erlang code >>> from your browser. For now it is there: >>> >>> http://tryerl.seriyps.ru/ >>> >>> How it works >>> Each request is handled by Cowboy web server, which launches new Erlang >>> VM instance per request inside lightweight linux container, based on >>> https://github.com/thestinger/playpen. There are restrictions on >>> networking, memory and execution time, but nothing else. >>> >>> What does it have >>> As you already heard, there is erlang code evaluation, but also >>> compilation to several intermediate formats, like core erlang, macros >>> expanding, beam and erlang assemblers and so on. And all this can be >>> launched under any erlang release version (for now it's only the latter 8, >>> but I can add more by demand). >>> Of course, there is 'pastebin' functionality, so you can save and share >>> snippet with somebody else. >>> >>> Possible use-cases: >>> * Explore code compatibility with all Erlang releases >>> * Share runnable erlang snippet with somebody >>> * Try to launch some dangerous code >>> * Quickly explore how your code is compiled to erlang asm instructions >>> * Maybe, for some online studying / webinars. Students are don't even >>> need to install erlang on their computers >>> * In blog posts / articles / documentation - to make code snippets more >>> interactive >>> >>> Idea was borrowed from https://play.rust-lang.org/. >>> >>> P.S.: it will be great, if you suggest some funny / interesting code >>> snippets for ?Examples? section. >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> >> -- >> Roberto Aloi >> --- >> Website: http://roberto-aloi.com >> Twitter: @robertoaloi >> >> _______________________________________________ >> 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 > > -- ?????????? ????????? / Alexander Petrovsky, Skype: askjuise Phone: +7 914 8 820 815 -------------- next part -------------- An HTML attachment was scrubbed... URL: From seriy.pr@REDACTED Wed Feb 11 14:14:07 2015 From: seriy.pr@REDACTED (=?UTF-8?B?0KHQtdGA0LPQtdC5INCf0YDQvtGF0L7RgNC+0LI=?=) Date: Wed, 11 Feb 2015 16:14:07 +0300 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: Yes, you may explore JS source to find HTTP calls. I think API willn't change in time. For now it's POST /api/evaluate {code: code release: erlangRelease} POST /api/compile { code: code, release: erlangRelease, emit: beam | core | S | dis | P | E } POST /api/pastebin { code: code, release: erlangRelease, emit: beam | core | S | dis | P | E } GET /api/pastebin/ POST body can be JSON or x-www-form-urlencoded (Content-Type header inspected) It returns plaintext for now. 2015-02-11 15:50 GMT+03:00 Roberto Aloi : > Awesome stuff. I would consider migrating the tryerlang.org tutorials to > your sandbox, to remove many of its current limitations. > Is command evaluation available through an API? > > > On 11 February 2015 at 13:24, ?????? ???????? wrote: > >> I'm glad to announce a service, which allow to run arbitrary Erlang code >> from your browser. For now it is there: >> >> http://tryerl.seriyps.ru/ >> >> How it works >> Each request is handled by Cowboy web server, which launches new Erlang >> VM instance per request inside lightweight linux container, based on >> https://github.com/thestinger/playpen. There are restrictions on >> networking, memory and execution time, but nothing else. >> >> What does it have >> As you already heard, there is erlang code evaluation, but also >> compilation to several intermediate formats, like core erlang, macros >> expanding, beam and erlang assemblers and so on. And all this can be >> launched under any erlang release version (for now it's only the latter 8, >> but I can add more by demand). >> Of course, there is 'pastebin' functionality, so you can save and share >> snippet with somebody else. >> >> Possible use-cases: >> * Explore code compatibility with all Erlang releases >> * Share runnable erlang snippet with somebody >> * Try to launch some dangerous code >> * Quickly explore how your code is compiled to erlang asm instructions >> * Maybe, for some online studying / webinars. Students are don't even >> need to install erlang on their computers >> * In blog posts / articles / documentation - to make code snippets more >> interactive >> >> Idea was borrowed from https://play.rust-lang.org/. >> >> P.S.: it will be great, if you suggest some funny / interesting code >> snippets for ?Examples? section. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > > > -- > Roberto Aloi > --- > Website: http://roberto-aloi.com > Twitter: @robertoaloi > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eriksoe@REDACTED Wed Feb 11 14:15:41 2015 From: eriksoe@REDACTED (=?UTF-8?Q?Erik_S=C3=B8e_S=C3=B8rensen?=) Date: Wed, 11 Feb 2015 14:15:41 +0100 Subject: [erlang-questions] SSL performance In-Reply-To: References: Message-ID: An observation: Your receive code looks dodgy - you receive only the first chunk of data, not everything up till tcp_closed / ssl_closed. That is probably not what you want. Besides that: is the time linear in the data size? Try measuring eg for 100MB and 200MB. (I suspect with the code you presented it would give the same durations independent of data size.) /Erik Den 11/02/2015 12.39 skrev "SeanD" : > Hi, > > We are experiencing a bottleneck in our application that has the option of > using SSL. Conducting some generic tests, I am seeing that SSL can be upto > 20,000 times slower when processing large amounts of data and was wondering > if anyone else has seen the same behaviour or can tell me that I'm doing > something really silly? > > Transferring a 200MB binary between 2 nodes on the same machine using > gen_tcp is taking between 100 and 200 microseconds, whilst transferring the > same binary using ssl usually takes around 3 seconds! I'm currently using > R16B01, but can happily move to a later version if this is required. > > Is there any way to speed this up or any alternative SSL implementations > that call out to openssl natively that could be used instead? Any insights > would be very welcome. > > Thanks, > Sean > > P.S. The code I'm using is enclosed below: > > -module(network_performance). > > -export([client/0,ssl_client/0,server/1,ssl_server/1]). > > client() -> > SomeHostInNet = "localhost", % to make it runnable on one machine > {ok, Sock} = gen_tcp:connect(SomeHostInNet, 5678, > [binary, {packet, 0}, {active, once}]), > Before = erlang:now(), > ok = do_client_recv(Sock), > After = erlang:now(), > ok = gen_tcp:close(Sock), > io:format("Time taken: ~p microsecs~n",[total_microsecs(After) - > total_microsecs(Before)]). > > server(Data) -> > {ok, LSock} = gen_tcp:listen(5678, [binary, {packet, raw}, {active, > once},{reuseaddr,true}]), > {ok, Sock} = gen_tcp:accept(LSock), > gen_tcp:send(Sock, Data), > gen_tcp:close(Sock). > > ssl_client() -> > SomeHostInNet = "localhost", % to make it runnable on one machine > ssl:start(), > {ok, Sock} = ssl:connect(SomeHostInNet, 5679, > [binary, {packet, 0}, {active, once}]), > ok = ssl:ssl_accept(Sock), > Before = erlang:now(), > ok = do_client_recv(Sock), > After = erlang:now(), > ok = ssl:close(Sock), > io:format("Time taken: ~p microsecs~n",[total_microsecs(After) - > total_microsecs(Before)]). > > ssl_server(Data) -> > ssl:start(), > {ok, LSock} = ssl:listen(5679, [binary, {packet, raw}, > {active, > once},{reuseaddr,true},{certfile,"test.pem"},{keyfile,"test.key"}]), > {ok, Sock} = ssl:transport_accept(LSock), > ok = ssl:ssl_accept(Sock), > ssl:send(Sock, Data), > ssl:close(Sock). > > total_microsecs({MegaSecs,Secs,MicroSecs}) -> > (MegaSecs*1000000 + Secs)*1000000 + MicroSecs. > > do_client_recv(Socket) -> > receive > {tcp, Socket, _Data} -> > ok; > {ssl, Socket, _Data} -> > ok; > {tcp_closed, Socket} -> > io:format("Socket closed~n",[]); > {tcp_error, Socket, Reason} -> > io:format("Error: ~p~n",[Reason]) > after 20000 -> > io:format("Receive timed out~n",[]) > end. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From seriy.pr@REDACTED Wed Feb 11 14:15:51 2015 From: seriy.pr@REDACTED (=?UTF-8?B?0KHQtdGA0LPQtdC5INCf0YDQvtGF0L7RgNC+0LI=?=) Date: Wed, 11 Feb 2015 16:15:51 +0300 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: I'm not so familiar with docker. Sandboxing part was borrowed from https://github.com/rust-lang/rust-playpen , so, if tryerl is vulnerable, that means that https://play.rust-lang.org/ is vulnerable too. 2015-02-11 15:53 GMT+03:00 pablo platt : > How is the playpen sandbox different from docker? > I know that docker is not 100% secure but it is very popular so the chance > for security holes to be found might be higher. > > On Wed, Feb 11, 2015 at 2:50 PM, Roberto Aloi wrote: > >> Awesome stuff. I would consider migrating the tryerlang.org tutorials to >> your sandbox, to remove many of its current limitations. >> Is command evaluation available through an API? >> >> >> On 11 February 2015 at 13:24, ?????? ???????? wrote: >> >>> I'm glad to announce a service, which allow to run arbitrary Erlang code >>> from your browser. For now it is there: >>> >>> http://tryerl.seriyps.ru/ >>> >>> How it works >>> Each request is handled by Cowboy web server, which launches new Erlang >>> VM instance per request inside lightweight linux container, based on >>> https://github.com/thestinger/playpen. There are restrictions on >>> networking, memory and execution time, but nothing else. >>> >>> What does it have >>> As you already heard, there is erlang code evaluation, but also >>> compilation to several intermediate formats, like core erlang, macros >>> expanding, beam and erlang assemblers and so on. And all this can be >>> launched under any erlang release version (for now it's only the latter 8, >>> but I can add more by demand). >>> Of course, there is 'pastebin' functionality, so you can save and share >>> snippet with somebody else. >>> >>> Possible use-cases: >>> * Explore code compatibility with all Erlang releases >>> * Share runnable erlang snippet with somebody >>> * Try to launch some dangerous code >>> * Quickly explore how your code is compiled to erlang asm instructions >>> * Maybe, for some online studying / webinars. Students are don't even >>> need to install erlang on their computers >>> * In blog posts / articles / documentation - to make code snippets more >>> interactive >>> >>> Idea was borrowed from https://play.rust-lang.org/. >>> >>> P.S.: it will be great, if you suggest some funny / interesting code >>> snippets for ?Examples? section. >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> >> >> -- >> Roberto Aloi >> --- >> Website: http://roberto-aloi.com >> Twitter: @robertoaloi >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From seriy.pr@REDACTED Wed Feb 11 14:25:41 2015 From: seriy.pr@REDACTED (=?UTF-8?B?0KHQtdGA0LPQtdC5INCf0YDQvtGF0L7RgNC+0LI=?=) Date: Wed, 11 Feb 2015 16:25:41 +0300 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: Yeah, that's ok. It's still inside sandbox. You may also try to explore filesystem http://tryerl.seriyps.ru/#id=33f6 or see process list http://tryerl.seriyps.ru/#id=12f2 2015-02-11 16:10 GMT+03:00 Vladimir Dronnikov : > ``` > % -*- coding: utf8 -*- > -module(bomb). > -export([loop/0, main/0]). > -import(lists, [map/2]). > -import(pg2, [pid/0, join/2, get_members/1]). > > loop() -> > join(forks, pid()), > > receive > _ -> spawn(bomb, loop, []), > loop() > end. > > main(_) -> > spawn(bomb, loop, []), > > case get_members(forks) of > [Pid|Pids] -> map(fun(P) -> P ! 1 end, [Pid|Pids]); > _ -> error > end, > main(1). > > main() -> main(0). > ``` > exposes some internal guts to the browser ;) Please check if it's > harmless. Good resource. Thank you. > --V > > On Wed, Feb 11, 2015 at 3:24 PM, ?????? ???????? > wrote: > >> I'm glad to announce a service, which allow to run arbitrary Erlang code >> from your browser. For now it is there: >> >> http://tryerl.seriyps.ru/ >> >> How it works >> Each request is handled by Cowboy web server, which launches new Erlang >> VM instance per request inside lightweight linux container, based on >> https://github.com/thestinger/playpen. There are restrictions on >> networking, memory and execution time, but nothing else. >> >> What does it have >> As you already heard, there is erlang code evaluation, but also >> compilation to several intermediate formats, like core erlang, macros >> expanding, beam and erlang assemblers and so on. And all this can be >> launched under any erlang release version (for now it's only the latter 8, >> but I can add more by demand). >> Of course, there is 'pastebin' functionality, so you can save and share >> snippet with somebody else. >> >> Possible use-cases: >> * Explore code compatibility with all Erlang releases >> * Share runnable erlang snippet with somebody >> * Try to launch some dangerous code >> * Quickly explore how your code is compiled to erlang asm instructions >> * Maybe, for some online studying / webinars. Students are don't even >> need to install erlang on their computers >> * In blog posts / articles / documentation - to make code snippets more >> interactive >> >> Idea was borrowed from https://play.rust-lang.org/. >> >> P.S.: it will be great, if you suggest some funny / interesting code >> snippets for ?Examples? section. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From seriy.pr@REDACTED Wed Feb 11 14:27:21 2015 From: seriy.pr@REDACTED (=?UTF-8?B?0KHQtdGA0LPQtdC5INCf0YDQvtGF0L7RgNC+0LI=?=) Date: Wed, 11 Feb 2015 16:27:21 +0300 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: There are already http://tryerlang.org/, but it's very restricted. 2015-02-11 16:13 GMT+03:00 Alexander Petrovsky : > Maybe someone will be interesting to see at my version "tryerl" - > https://github.com/juise/sherly. > > I think will be interesting to combine tryerl and sherly, do smth like > tryclj.com > > 2015-02-11 12:53 GMT+00:00 pablo platt : > >> How is the playpen sandbox different from docker? >> I know that docker is not 100% secure but it is very popular so the >> chance for security holes to be found might be higher. >> >> On Wed, Feb 11, 2015 at 2:50 PM, Roberto Aloi wrote: >> >>> Awesome stuff. I would consider migrating the tryerlang.org tutorials >>> to your sandbox, to remove many of its current limitations. >>> Is command evaluation available through an API? >>> >>> >>> On 11 February 2015 at 13:24, ?????? ???????? >>> wrote: >>> >>>> I'm glad to announce a service, which allow to run arbitrary Erlang >>>> code from your browser. For now it is there: >>>> >>>> http://tryerl.seriyps.ru/ >>>> >>>> How it works >>>> Each request is handled by Cowboy web server, which launches new Erlang >>>> VM instance per request inside lightweight linux container, based on >>>> https://github.com/thestinger/playpen. There are restrictions on >>>> networking, memory and execution time, but nothing else. >>>> >>>> What does it have >>>> As you already heard, there is erlang code evaluation, but also >>>> compilation to several intermediate formats, like core erlang, macros >>>> expanding, beam and erlang assemblers and so on. And all this can be >>>> launched under any erlang release version (for now it's only the latter 8, >>>> but I can add more by demand). >>>> Of course, there is 'pastebin' functionality, so you can save and share >>>> snippet with somebody else. >>>> >>>> Possible use-cases: >>>> * Explore code compatibility with all Erlang releases >>>> * Share runnable erlang snippet with somebody >>>> * Try to launch some dangerous code >>>> * Quickly explore how your code is compiled to erlang asm instructions >>>> * Maybe, for some online studying / webinars. Students are don't even >>>> need to install erlang on their computers >>>> * In blog posts / articles / documentation - to make code snippets more >>>> interactive >>>> >>>> Idea was borrowed from https://play.rust-lang.org/. >>>> >>>> P.S.: it will be great, if you suggest some funny / interesting code >>>> snippets for ?Examples? section. >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> >>> >>> -- >>> Roberto Aloi >>> --- >>> Website: http://roberto-aloi.com >>> Twitter: @robertoaloi >>> >>> _______________________________________________ >>> 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 >> >> > > > -- > ?????????? ????????? / Alexander Petrovsky, > > Skype: askjuise > Phone: +7 914 8 820 815 > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dronnikov@REDACTED Wed Feb 11 14:36:37 2015 From: dronnikov@REDACTED (Vladimir Dronnikov) Date: Wed, 11 Feb 2015 16:36:37 +0300 Subject: [erlang-questions] [ANN] TryErl: run Erlang code online In-Reply-To: References: Message-ID: Good On Wed, Feb 11, 2015 at 4:25 PM, ?????? ???????? wrote: > Yeah, that's ok. It's still inside sandbox. You may also try to explore > filesystem > http://tryerl.seriyps.ru/#id=33f6 > or see process list > http://tryerl.seriyps.ru/#id=12f2 > > 2015-02-11 16:10 GMT+03:00 Vladimir Dronnikov : > >> ``` >> % -*- coding: utf8 -*- >> -module(bomb). >> -export([loop/0, main/0]). >> -import(lists, [map/2]). >> -import(pg2, [pid/0, join/2, get_members/1]). >> >> loop() -> >> join(forks, pid()), >> >> receive >> _ -> spawn(bomb, loop, []), >> loop() >> end. >> >> main(_) -> >> spawn(bomb, loop, []), >> >> case get_members(forks) of >> [Pid|Pids] -> map(fun(P) -> P ! 1 end, [Pid|Pids]); >> _ -> error >> end, >> main(1). >> >> main() -> main(0). >> ``` >> exposes some internal guts to the browser ;) Please check if it's >> harmless. Good resource. Thank you. >> --V >> >> On Wed, Feb 11, 2015 at 3:24 PM, ?????? ???????? >> wrote: >> >>> I'm glad to announce a service, which allow to run arbitrary Erlang code >>> from your browser. For now it is there: >>> >>> http://tryerl.seriyps.ru/ >>> >>> How it works >>> Each request is handled by Cowboy web server, which launches new Erlang >>> VM instance per request inside lightweight linux container, based on >>> https://github.com/thestinger/playpen. There are restrictions on >>> networking, memory and execution time, but nothing else. >>> >>> What does it have >>> As you already heard, there is erlang code evaluation, but also >>> compilation to several intermediate formats, like core erlang, macros >>> expanding, beam and erlang assemblers and so on. And all this can be >>> launched under any erlang release version (for now it's only the latter 8, >>> but I can add more by demand). >>> Of course, there is 'pastebin' functionality, so you can save and share >>> snippet with somebody else. >>> >>> Possible use-cases: >>> * Explore code compatibility with all Erlang releases >>> * Share runnable erlang snippet with somebody >>> * Try to launch some dangerous code >>> * Quickly explore how your code is compiled to erlang asm instructions >>> * Maybe, for some online studying / webinars. Students are don't even >>> need to install erlang on their computers >>> * In blog posts / articles / documentation - to make code snippets more >>> interactive >>> >>> Idea was borrowed from https://play.rust-lang.org/. >>> >>> P.S.: it will be great, if you suggest some funny / interesting code >>> snippets for <> section. >>> >>> _______________________________________________ >>> 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 Wed Feb 11 15:01:45 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 11 Feb 2015 15:01:45 +0100 Subject: [erlang-questions] Mnesia create tables best practices In-Reply-To: <7A8865DD-DD04-4637-B965-85CD9014873E@widetag.com> References: <87467EDF-C075-4F77-8993-C4108D2432A6@widetag.com> <7A8865DD-DD04-4637-B965-85CD9014873E@widetag.com> Message-ID: On Wed, Feb 11, 2015 at 9:07 AM, Roberto Ostinelli < roberto.ostinelli@REDACTED> wrote: > Adding to this: doesn't it mean that the name and full host of the node > need to be known before you can initialize your db, hence a release can > only be specific for a specific full node name? Indeed, distributed mnesia requires a node list when creating the schema. So this makes the database specific to the installation. This is not unique in any way, as RDBMS systems in general has this requirement of "pool initialization", where initial schemas, clustering and replication configuration has to happen. In this case, schema creation needs a separate target, and it is often beneficial to store the mnesia dir outside the release for easier upgrades. What I'm coming at is that mnesia was not created for idempotent database initialization. Other systems may be far better at this, where one can join new nodes to an existing system dynamically. The task is even automatic in some systems. But for mnesia, you need to write code. Code gives control and flexibility at the expense of simple deployment. On the other hand, you wont be surprised by system behaviour since you wrote the code yourself. Here is one way to go about it. Initialize a ``root'' which stores the schema and uses a predefined schema upon boot. Every other node now joins the cluster, with an empty schema. You start mnesia on a new node. You call `mnesia:change_config(extra_db_nodes, ['joiner@REDACTED'])` on root followed by `mnesia:change_table_copy(schema, 'joiner@REDACTED', disc_copies)` so the schema is on the disc of the newly joined node. >From here, you can run `mnesia:add_table_copy(Table, 'joiner@REDACTED', Type)` to copy tables to the newly joined node for the tables which needs to be added. In turn, you have two release configurations. One in which the node boots with a predefined schema, and one where it boots in a ram_copies schema mode and doesn't start operating before it has been joined to a cluster. Once it has been joined, it has a valid mnesia database and is ready for doing work in the cluster. If you want the ability to truly elastically add and remove nodes from a cluster, you probably shouldn't use mnesia. The reason has to do with mnesia's inability to automatically work with network splits and split brain. You can add nodes to mnesia ``up to a point'', after which you will have to move to another database system. As I've argued before[0], in the sense of the CAP theorem, mnesia is neither CP, nor AP and ``CA'' doesn't exist as a mode. Remember that mnesia predates the CAP theorem by a couple of years, and partitioning is highly unlikely in a system where communication is on the same cross-backplane as your telephony switching calls. For AP systems, Riak is perhaps the weapon of choice for Erlang programmers. For a CP system, I don't really have a good elastic candidate, but others may. Where mnesia shines are: * The cluster is of moderate size, perhaps less than 16 nodes. * The FULL database can be in memory, or if using fragmented tables, loss of a fragment is not equal to total system catastrophe. * Interaction between the Erlang processes and the data is tight, so having access to QLC is important. * You have most queries as K/V lookups requiring microsecond latency with few complicated queries joining many tables. In the latter case, you care about correctness, not latency. * The most likely failure is loss of a node. It happens rarely and it is possible to solve through manual intervention in a window of a couple of days/weeks. [0] https://medium.com/@jlouis666/mnesia-and-cap-d2673a92850 -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Wed Feb 11 15:32:59 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 11 Feb 2015 15:32:59 +0100 Subject: [erlang-questions] SSL performance In-Reply-To: References: Message-ID: On Wed, Feb 11, 2015 at 12:38 PM, SeanD wrote: > Transferring a 200MB binary between 2 nodes on the same machine using > gen_tcp is taking between 100 and 200 microseconds, whilst transferring the > same binary using ssl usually takes around 3 seconds! I'm currently using > R16B01, but can happily move to a later version if this is required. I have a Core i7-4900MQ, which is a pretty fast Haswell core. Using the crypto application, encrypting 200 megabytes of 0'es with aes_ctr mode, IV = 16 bytes of 0'es, key = binary:copy(<<"foobar">>, 4) (192 bit key) takes 1.7 seconds. This is going to be the lower bound of an AES stream in CTR mode. If your core is slower, then 3 seconds doesn't sound wrong. Using the `enacl` application[0], Running 200 megabytes of 0'es through a secretbox (xsalsa20 cipher + poly1305 MAC!, it is more secure than AES-CTR) with a nonce of 24 bytes and a 256 bit secret key takes 397 milliseconds. If you had picked a sane cryptographic library, this would have been the lower limit :) Fact is, I can encrypt-then-mac 4.3 times faster than SSL can encrypt in AES-CTR mode. In any case, I don't think you are experiencing anything odd, besides slow cryptographic primitives. [0] https://github.com/jlouis/enacl - Full disclosure: I'm the author, and it requires OTP 17.3+ since it uses Steve Vinoski's dirty scheduler feature. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From sergej.jurecko@REDACTED Wed Feb 11 16:23:25 2015 From: sergej.jurecko@REDACTED (Sergej Jurecko) Date: Wed, 11 Feb 2015 16:23:25 +0100 Subject: [erlang-questions] [ANN] detest: Tool for running tests on a cluster of erlang nodes Message-ID: Hello Criticisms and suggestions welcome: https://github.com/biokoda/detest Detest is a tool for running distributed erlang tests. It is designed to be simple and flexible. It sets up a distributed environment of multiple nodes, then it calls your code to do whatever you wish with that environment. As a parameter it takes in path to your test script. This script needs to export at least: cfg/1, run/1, setup/1, cleanup/1. Detest is configured with your cfg/1 function within the script. It instructs detest how many nodes to run, where their configuration files are, how to execute your app, etc. Detest will then execute the nodes, connect to each (as a hidden node) wait for your app to start, then call run/1 function in your script. You are then free to do whatever you wish. RPC is possible to any of the nodes. You can also terminate the test at any time by entering q to terminal. Run it like so: ./detest test/test.erl You can print all console output from your nodes: ./detest -v test/test.erl You can also send arguments to your script: ./detest -v test/test.erl dotest1 If you are on linux and willing to run detest as sudo, it will use damocles library to create seperate network interfaces for every node that you have configured. You can then call damocles library directly and create various network condition like packetloss, delays or network splits between nodes. detest will create a folder named .detest in at location it is running from. This is where node logs and state should go. For an example look at: test/test.erl and test/app.config Sergej From aschultz@REDACTED Wed Feb 11 16:29:43 2015 From: aschultz@REDACTED (Andreas Schultz) Date: Wed, 11 Feb 2015 15:29:43 +0000 (UTC) Subject: [erlang-questions] SSL performance In-Reply-To: <1149051395.2182910.1423668563780.JavaMail.zimbra@tpip.net> References: Message-ID: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> Hi Jesper, salsa20 might be indeed faster that AES-CTR, but you comparison is clearly biased ;-) ----- On 11 Feb, 2015, at 15:32, Jesper Louis Andersen jesper.louis.andersen@REDACTED wrote: [...] > Using the crypto application, encrypting 200 megabytes of 0'es with aes_ctr > mode, IV = 16 bytes of 0'es, key = binary:copy(<<"foobar">>, 4) (192 bit key) > takes 1.7 seconds. This is going to be the lower bound of an AES stream in CTR > mode. If your core is slower, then 3 seconds doesn't sound wrong. > > Using the `enacl` application[0], Running 200 megabytes of 0'es through a > secretbox (xsalsa20 cipher + poly1305 MAC!, it is more secure than AES-CTR) > with a nonce of 24 bytes and a 256 bit secret key takes 397 milliseconds. If > you had picked a sane cryptographic library, this would have been the lower > limit :) The cause for this is not the cryptographic library, but Erlang's interface to it. Erlang's crypto application uses a non-optimized OpenSSL API to execute the AES encryption, while enacl seems to uses an highly optimized version. Normally when doing AES, you first have to schedule the key, creating an encryption context and then reuse that context for every block. Since the crypto application doesn't have stream_cipher versions of AES, it has to go through the key scheduling on every invocation (every block). Also, OpenSSL can use assembler optimized AES functions on modern CPU's, but those are only available when OpenSSL's EVP interfaces are used. Erlang's crypto does not use those. So, don't blame the speed on the cryptographic library, but on the interface to it. When you want to compare the raw speed of crypto functions in OpenSSL, you should use 'openssl speed', e.g. 'openssl speed -evp aes-192-ctr'. On my Intel i7-2760QM CPU @ 2.40GHz I get this: The 'numbers' are in 1000s of bytes per second processed. type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes aes-192-ctr 409914.49k 1352747.82k 2235027.29k 2834907.01k 3064111.10k aes-192-gcm 266250.60k 694806.52k 953150.46k 1046909.52k 1073790.98k So, even the slowest version with 16 Bytes/block achieves 266 MByte/s. Andreas > Fact is, I can encrypt-then-mac 4.3 times faster than SSL can encrypt in AES-CTR > mode. > > In any case, I don't think you are experiencing anything odd, besides slow > cryptographic primitives. > > [0] https://github.com/jlouis/enacl - Full disclosure: I'm the author, and it > requires OTP 17.3+ since it uses Steve Vinoski's dirty scheduler feature. > > > > -- > J. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- -- Dipl. Inform. Andreas Schultz email: as@REDACTED phone: +49-391-819099-224 mobil: +49-170-2226073 ------------------- enabling your networks ------------------- Travelping GmbH phone: +49-391-819099229 Roentgenstr. 13 fax: +49-391-819099299 D-39108 Magdeburg email: info@REDACTED GERMANY web: http://www.travelping.com Company Registration: Amtsgericht Stendal Reg No.: HRB 10578 Geschaeftsfuehrer: Holger Winkelmann | VAT ID No.: DE236673780 -------------------------------------------------------------- From jesper.louis.andersen@REDACTED Wed Feb 11 16:48:50 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Wed, 11 Feb 2015 16:48:50 +0100 Subject: [erlang-questions] SSL performance In-Reply-To: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> References: <1149051395.2182910.1423668563780.JavaMail.zimbra@tpip.net> <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> Message-ID: On Wed, Feb 11, 2015 at 4:29 PM, Andreas Schultz wrote: > So, don't blame the speed on the cryptographic library, but on the > interface to it. This should perhaps have been in a highlighted position. Yes, indeed, the interface is the problem. Since `ssl`, the Erlang application is using this interface however, it becomes a bound on the speed, which was kind of the primary point. The secondary point about enacl is that we can do better, much better. The salsa20 suite of ciphers (salsa20, xsalsa20 and chacha20) are all considerably faster than AES, even with optimizations, for the same or better security margin. Combined with a bad interface, the speed difference becomes noticable to the point where it begins to matter. Enacl could be optimized further and currently includes a tradeoff where it copies the 200 megabytes for a nicer interface. Exposing a worse interface could avoid that copy altogether for really speed-sensitive programs. Of couse I'm biased :P -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jon@REDACTED Wed Feb 11 16:53:03 2015 From: jon@REDACTED (Jon Schneider) Date: Wed, 11 Feb 2015 15:53:03 -0000 Subject: [erlang-questions] SSL performance In-Reply-To: References: <1149051395.2182910.1423668563780.JavaMail.zimbra@tpip.net> <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> Message-ID: <739d4c3505f33300e2efc193f5b2acd7.squirrel@mail.jschneider.net> But I'd still like to know whether it's all about transferring data between nodes on the same machine where surely encryption is unnecessary because the OS ought be able to provide this security or across ethernet where gigabit speed has already been achieved. Or are we talking 10Gbps ? Jon From aschultz@REDACTED Wed Feb 11 16:57:32 2015 From: aschultz@REDACTED (Andreas Schultz) Date: Wed, 11 Feb 2015 15:57:32 +0000 (UTC) Subject: [erlang-questions] SSL performance In-Reply-To: <2106927260.2183207.1423670232471.JavaMail.zimbra@tpip.net> References: <1149051395.2182910.1423668563780.JavaMail.zimbra@tpip.net> <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> Message-ID: <1820588376.2183208.1423670252567.JavaMail.zimbra@tpip.net> ----- On 11 Feb, 2015, at 16:48, Jesper Louis Andersen jesper.louis.andersen@REDACTED wrote: > On Wed, Feb 11, 2015 at 4:29 PM, Andreas Schultz wrote: > >> So, don't blame the speed on the cryptographic library, but on the >> interface to it. > > > This should perhaps have been in a highlighted position. Yes, indeed, the > interface is the problem. Since `ssl`, the Erlang application is using this > interface however, it becomes a bound on the speed, which was kind of the > primary point. > > The secondary point about enacl is that we can do better, much better. The > salsa20 suite of ciphers (salsa20, xsalsa20 and chacha20) are all > considerably faster than AES, even with optimizations, for the same or > better security margin. Combined with a bad interface, the speed difference > becomes noticable to the point where it begins to matter. Enacl could be > optimized further and currently includes a tradeoff where it copies the 200 > megabytes for a nicer interface. Exposing a worse interface could avoid > that copy altogether for really speed-sensitive programs. BTW: Erlang 18 when compiled on libressl or a recent/patched OpenSSL will have the ChaCha20/Policy1305 AEAD cipher for TLS [1]. The crypto interface is still not optimal, but it would be interesting to compare that to enacl. [1]: https://github.com/erlang/otp/commit/fb9d36c2c7c1bd4760d0be2801b9c2852d3502bf https://github.com/erlang/otp/commit/7603a4029514a644c8323028b06acdc33e45b286 Andreas > > Of couse I'm biased :P > > > -- > J. -- -- Dipl. Inform. Andreas Schultz From essen@REDACTED Wed Feb 11 16:59:20 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Wed, 11 Feb 2015 16:59:20 +0100 Subject: [erlang-questions] SSL performance In-Reply-To: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> References: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> Message-ID: <54DB7C58.4010203@ninenines.eu> On 02/11/2015 04:29 PM, Andreas Schultz wrote: > The cause for this is not the cryptographic library, but Erlang's interface to it. > Erlang's crypto application uses a non-optimized OpenSSL API to execute the AES > encryption, while enacl seems to uses an highly optimized version. > > Normally when doing AES, you first have to schedule the key, creating an encryption > context and then reuse that context for every block. Since the crypto application > doesn't have stream_cipher versions of AES, it has to go through the key scheduling > on every invocation (every block). Also, OpenSSL can use assembler optimized AES > functions on modern CPU's, but those are only available when OpenSSL's EVP interfaces > are used. Erlang's crypto does not use those. I have seen some work around EVP in the past few months. Is this not what you are talking about? commit 425a34001fdd5de8396c5c9903f4f38a9d49a15c Author: Alex Wilson Date: Thu Oct 9 21:39:29 2014 +1000 crypto: use EVP for AES-CBC This enables the use of hardware acceleration for AES crypto on newer Intel CPUs (AES-NI), among other platforms. Cheers. -- Lo?c Hoguin http://ninenines.eu From aschultz@REDACTED Wed Feb 11 17:11:42 2015 From: aschultz@REDACTED (Andreas Schultz) Date: Wed, 11 Feb 2015 16:11:42 +0000 (UTC) Subject: [erlang-questions] SSL performance In-Reply-To: <314615231.2183310.1423671054408.JavaMail.zimbra@tpip.net> References: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> <54DB7C58.4010203@ninenines.eu> Message-ID: <1496919824.2183311.1423671102176.JavaMail.zimbra@tpip.net> ----- On 11 Feb, 2015, at 16:59, Lo?c Hoguin essen@REDACTED wrote: > On 02/11/2015 04:29 PM, Andreas Schultz wrote: >> The cause for this is not the cryptographic library, but Erlang's interface to >> it. >> Erlang's crypto application uses a non-optimized OpenSSL API to execute the AES >> encryption, while enacl seems to uses an highly optimized version. >> >> Normally when doing AES, you first have to schedule the key, creating an >> encryption >> context and then reuse that context for every block. Since the crypto >> application >> doesn't have stream_cipher versions of AES, it has to go through the key >> scheduling >> on every invocation (every block). Also, OpenSSL can use assembler optimized AES >> functions on modern CPU's, but those are only available when OpenSSL's EVP >> interfaces >> are used. Erlang's crypto does not use those. > > I have seen some work around EVP in the past few months. Is this not > what you are talking about? > > commit 425a34001fdd5de8396c5c9903f4f38a9d49a15c > Author: Alex Wilson > Date: Thu Oct 9 21:39:29 2014 +1000 > > crypto: use EVP for AES-CBC > > This enables the use of hardware acceleration for AES crypto > on newer Intel CPUs (AES-NI), among other platforms. That is a good step in the right direction. Still, it has to recreate the EVP crypto context for every invocation. There was a discussion about keeping the EVP context between invocations and use the crypto stream_encrypt/decrypt instead. That would eliminate the overhead of the context creation between calls. Andreas > Cheers. > > -- > Lo?c Hoguin > http://ninenines.eu -- -- Dipl. Inform. Andreas Schultz From sean@REDACTED Wed Feb 11 17:30:49 2015 From: sean@REDACTED (Sean Cribbs) Date: Wed, 11 Feb 2015 10:30:49 -0600 Subject: [erlang-questions] SSL performance In-Reply-To: <1496919824.2183311.1423671102176.JavaMail.zimbra@tpip.net> References: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> <54DB7C58.4010203@ninenines.eu> <314615231.2183310.1423671054408.JavaMail.zimbra@tpip.net> <1496919824.2183311.1423671102176.JavaMail.zimbra@tpip.net> Message-ID: It doesn't sound like you're running into this, but we recently found there to be a potential deadlock in the ssl connection under high throughput, patched on our fork of OTP here: https://github.com/basho/otp/commit/e237383fe002af4f63f8419b35bac6f435856a38 On Wed, Feb 11, 2015 at 10:11 AM, Andreas Schultz wrote: > > > ----- On 11 Feb, 2015, at 16:59, Lo?c Hoguin essen@REDACTED wrote: > > > On 02/11/2015 04:29 PM, Andreas Schultz wrote: > >> The cause for this is not the cryptographic library, but Erlang's > interface to > >> it. > >> Erlang's crypto application uses a non-optimized OpenSSL API to execute > the AES > >> encryption, while enacl seems to uses an highly optimized version. > >> > >> Normally when doing AES, you first have to schedule the key, creating an > >> encryption > >> context and then reuse that context for every block. Since the crypto > >> application > >> doesn't have stream_cipher versions of AES, it has to go through the key > >> scheduling > >> on every invocation (every block). Also, OpenSSL can use assembler > optimized AES > >> functions on modern CPU's, but those are only available when OpenSSL's > EVP > >> interfaces > >> are used. Erlang's crypto does not use those. > > > > I have seen some work around EVP in the past few months. Is this not > > what you are talking about? > > > > commit 425a34001fdd5de8396c5c9903f4f38a9d49a15c > > Author: Alex Wilson > > Date: Thu Oct 9 21:39:29 2014 +1000 > > > > crypto: use EVP for AES-CBC > > > > This enables the use of hardware acceleration for AES crypto > > on newer Intel CPUs (AES-NI), among other platforms. > > That is a good step in the right direction. Still, it has to recreate the > EVP crypto context for every invocation. There was a discussion about > keeping the EVP context between invocations and use the crypto > stream_encrypt/decrypt instead. That would eliminate the overhead of the > context creation between calls. > > Andreas > > > Cheers. > > > > -- > > Lo?c Hoguin > > http://ninenines.eu > > -- > -- > Dipl. Inform. > Andreas Schultz > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Sean Cribbs Sr. Software Engineer Basho Technologies, Inc. http://basho.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From jim.rosenblum@REDACTED Wed Feb 11 17:48:20 2015 From: jim.rosenblum@REDACTED (Jim Rosenblum) Date: Wed, 11 Feb 2015 11:48:20 -0500 Subject: [erlang-questions] More Information: snmpm:register_agent/3 suddenly stopped working! In-Reply-To: <54DB13E6.1070908@yahoo.co.uk> References: <54DB13E6.1070908@yahoo.co.uk> Message-ID: <141F1B48-26BC-45DD-9D26-11860AB24335@gmail.com> Thanks, somehow I missed that. Thanks again! > On Feb 11, 2015, at 3:33 AM, Dominik Pawlak wrote: > > Hello Jim, > > snmp application has changed between 17.1 (snmp v4.25.1) and 17.4 (snmp v5.1.1). According to docs the address should look like: > > "Addr is the address in the transport domain, either an {IpAddr, IpPort} tuple or a traditional SNMP integer list containing port number. IpAddr is either a regular Erlang/OTP ip_address() or a traditional SNMP integer list not containing port number, and IpPort is an integer. > > ip_address() = ip4_address() | ip6_address() > ip4_address() = {0..255, 0..255, 0..255, 0..255}" > > I always used [127,0,0,1] or {127,0,0,1} and never had any problem with it, I have never tried with "127.0.0.1". > > Best > Dominik > >> On 11.02.2015 05:31, jim rosenblum wrote: >> More information: >> >> on 17.4 CentOS release 5.5 -- used to work before I upgraded from 17.1 >> > snmpm:register_agent(snmp_manager,"Hope", [{engine_id, "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"},{port,161}, {tdomain,transportDomainUdpIpv4},{sec_level, noAuthNoPriv},{sec_name, "initial"},{version, v2},{timeout,1000}]). >> > ok >> >> >> on 17.1 CentOS release 6.2 >> snmpm:register_agent(snmp_manager,"Hope", [{engine_id, "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"},{port,161}, {tdomain,transportDomainUdpIpv4},{sec_level, noAuthNoPriv},{sec_name, "initial"},{version, v2},{timeout,1000}]). >> >> {error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} >> >> >> >>> On Tue, Feb 10, 2015 at 10:40 PM, jim rosenblum wrote: >>> Folks, >>> >>> I have an application that uses snmp that used to work and all of a sudden doesn't - I did upgrade from 17.1 to 17.4 - but other than that nothing has changed that I know of. I am having trouble down-grading, so I cannot confirm that the upgrade is the culprit. >>> >>> When I do the following from a machine with IP address 10.6.81.19 >>> 1> snmpm:register_agent(hope,"Hope", [{engine_id, "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"}]). >>> >>> I get >>> {error,{bad_address,{snmpUDPDomain,"10.7.42.11"}}} >>> >>> I have an appropriate snmpd.conf on 10.7.42.11 that has >>> >>> com2sec sentrysrv 10.6.81.19/32 CLSENTRY >>> group CLROGroup v2c sentrysrv >>> view all included .1 80 >>> access CLROGroup "" v2c noauth exact all none none >>> >>> adding {tdomain, transportDomainUdpIpv4} to the option list results in the, essentially, same error: >>> {error,{bad_address,{{error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} >>> >>> >>> Both machines can ping each other. The snmpd daemon is running on .11, I have tried all kinds of additional options (port, etc.), but cannot get it to work >>> >>> This is *killing* me, can anyone point out what stupid thing I am doing wrong? >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From seand-erlang@REDACTED Wed Feb 11 18:58:48 2015 From: seand-erlang@REDACTED (SeanD) Date: Wed, 11 Feb 2015 17:58:48 +0000 Subject: [erlang-questions] SSL performance In-Reply-To: References: Message-ID: Thanks all, There have been a number of useful suggestions here around improving the test that I was carrying out. I've modified the code so that it uses {active,true} and can receive multiple chunks of data instead of one main chunk. I've also run the client and server on different machines and am seeing the difference in performance between gen_tcp and ssl decrease. It is now taking around 2 seconds to transfer 200MB of data using gen_tcp and taking around 10 seconds to transfer the same data using SSL. A few people had concerns about the way I was measuring the time taken, but I believe this should be ok as I only start measuring time after the initial connection has been established. Performance improves marginally if I send it in smaller chunks and the relationship between time taken and size of data seems linear too. The code enclosed was to demonstrate the difference in speed between gen_tcp and ssl and the updated results mirror the performance change I see in our own application when accessing data from a HTTPS server. (I have no control over the security mechanisms exposed by this server) For reference, my updated code is shown below. Cheers, Sean -module(network_performance). -export([client/0,ssl_client/0,server/1,server/2,ssl_server/1,ssl_server/2]). client() -> SomeHostInNet = "172.16.32.41", {ok, Sock} = gen_tcp:connect(SomeHostInNet, 5678, [binary, {packet, 0}, {active, true}]), Before = erlang:now(), ok = do_client_recv(Sock), After = erlang:now(), ok = gen_tcp:close(Sock), io:format("Time taken: ~p microsecs~n",[total_microsecs(After) - total_microsecs(Before)]). server(Data) -> server(Data,1). server(Data, NoOfIterations) -> {ok, LSock} = gen_tcp:listen(5678, [binary, {packet, raw}, {active, true},{reuseaddr,true}]), {ok, Sock} = gen_tcp:accept(LSock), send_tcp_data(Sock, Data, NoOfIterations), gen_tcp:close(Sock). ssl_client() -> SomeHostInNet = "172.16.32.41", ssl:start(), {ok, Sock} = ssl:connect(SomeHostInNet, 5679, [binary, {packet, raw}, {active, true}]), ok = ssl:ssl_accept(Sock), Before = erlang:now(), ok = do_client_recv(Sock), After = erlang:now(), ok = ssl:close(Sock), io:format("Time taken: ~p microsecs~n",[total_microsecs(After) - total_microsecs(Before)]). ssl_server(Data) -> ssl_server(Data, 1). ssl_server(_Data, 0) -> ok; ssl_server(Data, NoOfIterations) -> ssl:start(), {ok, LSock} = ssl:listen(5679, [binary, {packet, raw}, {active, true},{reuseaddr,true},{certfile,"test.pem"},{keyfile,"test.key"}]), {ok, Sock} = ssl:transport_accept(LSock), ok = ssl:ssl_accept(Sock), send_ssl_data(Sock, Data, NoOfIterations), ssl:close(Sock). send_tcp_data(_Sock, _Data, 0) -> ok; send_tcp_data(Sock, Data, NoOfIterations) -> gen_tcp:send(Sock, Data), send_tcp_data(Sock, Data, NoOfIterations - 1). send_ssl_data(_Sock, _Data, 0) -> ok; send_ssl_data(Sock, Data, NoOfIterations) -> ssl:send(Sock, Data), send_ssl_data(Sock, Data, NoOfIterations - 1). total_microsecs({MegaSecs,Secs,MicroSecs}) -> (MegaSecs*1000000 + Secs)*1000000 + MicroSecs. do_client_recv(Socket) -> do_client_recv(Socket, 0). do_client_recv(Socket, Acc) -> receive {tcp, Socket, Data} -> do_client_recv(Socket, Acc + byte_size(Data)); {ssl, Socket, Data} -> do_client_recv(Socket, Acc + byte_size(Data)); {tcp_closed, Socket} -> io:format("Socket closed after transferring ~p bytes of data~n",[Acc]); {ssl_closed, _Socket} -> io:format("Socket closed after transferring ~p bytes of data~n",[Acc]); {tcp_error, Socket, Reason} -> io:format("Error: ~p~n",[Reason]); {ssl_error, Socket, Reason} -> io:format("Error: ~p~n",[Reason]); Else -> io:format("Unexpected result: ~p~n",[Else]) after 20000 -> io:format("Receive timed out~n",[]) end. -------------- next part -------------- An HTML attachment was scrubbed... URL: From seand-erlang@REDACTED Wed Feb 11 19:12:18 2015 From: seand-erlang@REDACTED (SeanD) Date: Wed, 11 Feb 2015 18:12:18 +0000 Subject: [erlang-questions] SSL performance In-Reply-To: References: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> <54DB7C58.4010203@ninenines.eu> <314615231.2183310.1423671054408.JavaMail.zimbra@tpip.net> <1496919824.2183311.1423671102176.JavaMail.zimbra@tpip.net> Message-ID: Thanks for the deadlock fix details Sean. This may not be affecting the enclosed test, but could potentially occur in my real application. Lo?c, Andreas, Thanks for the hints about upcoming improvements. I'll look into those. Jesper, Thanks, We've to deal with HTTPS traffic, so am guessing enacl is of no use to me (at the moment) Jon, the test was just to try and reproduce issues similar to what I was seeing elsewhere when accessing HTTPS servers. I was testing on a single machine in order to stop the network being the bottleneck. See my earlier email to see results when using different machines for server and client. Thanks again all for your input, Sean On Wed, Feb 11, 2015 at 4:30 PM, Sean Cribbs wrote: > It doesn't sound like you're running into this, but we recently found > there to be a potential deadlock in the ssl connection under high > throughput, patched on our fork of OTP here: > > > https://github.com/basho/otp/commit/e237383fe002af4f63f8419b35bac6f435856a38 > > On Wed, Feb 11, 2015 at 10:11 AM, Andreas Schultz > wrote: > >> >> >> ----- On 11 Feb, 2015, at 16:59, Lo?c Hoguin essen@REDACTED wrote: >> >> > On 02/11/2015 04:29 PM, Andreas Schultz wrote: >> >> The cause for this is not the cryptographic library, but Erlang's >> interface to >> >> it. >> >> Erlang's crypto application uses a non-optimized OpenSSL API to >> execute the AES >> >> encryption, while enacl seems to uses an highly optimized version. >> >> >> >> Normally when doing AES, you first have to schedule the key, creating >> an >> >> encryption >> >> context and then reuse that context for every block. Since the crypto >> >> application >> >> doesn't have stream_cipher versions of AES, it has to go through the >> key >> >> scheduling >> >> on every invocation (every block). Also, OpenSSL can use assembler >> optimized AES >> >> functions on modern CPU's, but those are only available when OpenSSL's >> EVP >> >> interfaces >> >> are used. Erlang's crypto does not use those. >> > >> > I have seen some work around EVP in the past few months. Is this not >> > what you are talking about? >> > >> > commit 425a34001fdd5de8396c5c9903f4f38a9d49a15c >> > Author: Alex Wilson >> > Date: Thu Oct 9 21:39:29 2014 +1000 >> > >> > crypto: use EVP for AES-CBC >> > >> > This enables the use of hardware acceleration for AES crypto >> > on newer Intel CPUs (AES-NI), among other platforms. >> >> That is a good step in the right direction. Still, it has to recreate the >> EVP crypto context for every invocation. There was a discussion about >> keeping the EVP context between invocations and use the crypto >> stream_encrypt/decrypt instead. That would eliminate the overhead of the >> context creation between calls. >> >> Andreas >> >> > Cheers. >> > >> > -- >> > Lo?c Hoguin >> > http://ninenines.eu >> >> -- >> -- >> Dipl. Inform. >> Andreas Schultz >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Sean Cribbs > Sr. Software Engineer > Basho Technologies, Inc. > http://basho.com/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tuncer.ayaz@REDACTED Wed Feb 11 20:40:04 2015 From: tuncer.ayaz@REDACTED (Tuncer Ayaz) Date: Wed, 11 Feb 2015 20:40:04 +0100 Subject: [erlang-questions] [ANN] detest: Tool for running tests on a cluster of erlang nodes In-Reply-To: References: Message-ID: On Wed, Feb 11, 2015 at 4:23 PM, Sergej Jurecko wrote: > Hello > > Criticisms and suggestions welcome: > https://github.com/biokoda/detest > > Detest is a tool for running distributed erlang tests. It is > designed to be simple and flexible. It sets up a distributed > environment of multiple nodes, then it calls your code to do > whatever you wish with that environment. > > As a parameter it takes in path to your test script. This script > needs to export at least: cfg/1, run/1, setup/1, cleanup/1. > > Detest is configured with your cfg/1 function within the script. It > instructs detest how many nodes to run, where their configuration > files are, how to execute your app, etc. > > Detest will then execute the nodes, connect to each (as a hidden > node) wait for your app to start, then call run/1 function in your > script. You are then free to do whatever you wish. RPC is possible > to any of the nodes. You can also terminate the test at any time by > entering q to terminal. > > Run it like so: > > ./detest test/test.erl > > You can print all console output from your nodes: > > ./detest -v test/test.erl > > You can also send arguments to your script: > > ./detest -v test/test.erl dotest1 > > If you are on linux and willing to run detest as sudo, it will use > damocles library to create seperate network interfaces for every > node that you have configured. You can then call damocles library > directly and create various network condition like packetloss, > delays or network splits between nodes. > > detest will create a folder named .detest in at location it is > running from. This is where node logs and state should go. > > For an example look at: test/test.erl and test/app.config Thanks for sharing this, and allow me to ask: What are the advantages over common_test? From sergej.jurecko@REDACTED Wed Feb 11 21:26:12 2015 From: sergej.jurecko@REDACTED (Sergej Jurecko) Date: Wed, 11 Feb 2015 21:26:12 +0100 Subject: [erlang-questions] [ANN] detest: Tool for running tests on a cluster of erlang nodes In-Reply-To: References: Message-ID: <2DB7F638-EAB9-479C-B83A-62F563148B52@gmail.com> > > Thanks for sharing this, and allow me to ask: What are the advantages > over common_test? I wanted something that does not have a predefined structure. Just a simple tool that is easily understandable, that creates the environment and the config files. Then leaves me to do anything I wish. I wanted to add or stop as many nodes as I want during the test. I needed integration with erlydtl for config files (because we often use yaml or json files). I wanted something that is easily used with damocles to test network issues. Sergej From corticalcomputer@REDACTED Wed Feb 11 23:54:28 2015 From: corticalcomputer@REDACTED (Gene Sher) Date: Wed, 11 Feb 2015 17:54:28 -0500 Subject: [erlang-questions] Tracking down the reason for my Segmentation Fault (Core dump) problems. Message-ID: Hello List, Hardware: E5-Xeon 2697 v2, 32GB of RAM. OSes tried: Xubuntu 14.04.1 LTS, CentOS 7, Ubuntu 12.04 LTS Erlang versions the code was tried on: Erlang/OTP 17, R16, & R14 I have an issue where every time I use processes which contain within themselves large data structures (Large deep learning single process nodes), after just a minute or so Erlang core dumps. The amount of ram used is only about 2GB, so it can't be the system running out of memory, and its only using about 10 cores, since I'm only running 10 such processes. Now the same code, the same program, the same platform, functions without a problem when I keep these processes small (substantially smaller monolithic NN-module in each process). Everything is written purely in Erlang (No NIFs were involved in this particular NN code). What exactly is happening? is something running out of space? Can anyone recommend what option during the Erlang startup I should perhaps modify to alleviate the issue? There are no crushdump files that I can find, but I did get a core backtrace produced during one of these crashes when I was running erts-5.10.4, here is a partial paste of it: ccpp-2015-02-11-09\:18\:41-2273/core_backtrace: { "signal": 11 , "executable": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" , "stacktrace": [ { "crash_thread": true , "frames": [ { "address": 5352736 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 1158432 , "function_name": "sweep_one_area" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } , { "address": 5367589 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 1173285 , "function_name": "erts_garbage_collect" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } , { "address": 5369251 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 1174947 , "function_name": "erts_gc_after_bif_call" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } , { "address": 5871217 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 1676913 , "function_name": "nbif_3_gc_after_bif" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } ] } , { "frames": [ { "address": 1101651978 , "build_id_offset": 1101651978 } ] } , { "frames": [ { "address": 139994957883141 , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" , "build_id_offset": 46853 , "function_name": "pthread_cond_wait@@GLIBC_2.3.2" , "file_name": "/lib64/libpthread.so.0" } , { "address": 6128777 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 1934473 , "function_name": "ethr_cond_wait" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } , { "address": 4665919 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 471615 , "function_name": "sys_msg_dispatcher_func" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } , { "address": 6134325 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 1940021 , "function_name": "thr_wrapper" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } , { "address": 139994957868531 , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" , "build_id_offset": 32243 , "function_name": "start_thread" , "file_name": "/lib64/libpthread.so.0" } , { "address": 139994952778157 , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" , "build_id_offset": 1008045 , "function_name": "__clone" , "file_name": "/lib64/libc.so.6" } ] } , { "frames": [ { "address": 139994957894237 , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" , "build_id_offset": 57949 , "function_name": "read" , "file_name": "/lib64/libpthread.so.0" } , { "address": 5741674 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 1547370 , "function_name": "signal_dispatcher_thread_func" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } , { "address": 6134325 , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" , "build_id_offset": 1940021 , "function_name": "thr_wrapper" , "file_name": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" } , { "address": 139994957868531 , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" , "build_id_offset": 32243 , "function_name": "start_thread" , "file_name": "/lib64/libpthread.so.0" } , { "address": 139994952778157 , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" , "build_id_offset": 1008045 , "function_name": "__clone" , "file_name": "/lib64/libc.so.6" } ] } ... Thanks in advance for any suggestions and help, -Gene -------------- next part -------------- An HTML attachment was scrubbed... URL: From felixgallo@REDACTED Thu Feb 12 00:29:49 2015 From: felixgallo@REDACTED (Felix Gallo) Date: Wed, 11 Feb 2015 15:29:49 -0800 Subject: [erlang-questions] Tracking down the reason for my Segmentation Fault (Core dump) problems. In-Reply-To: References: Message-ID: What does it say when you type 'erl' at the command line? Example: Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false] Eshell V6.0 (abort with ^G) 1> On Wed, Feb 11, 2015 at 2:54 PM, Gene Sher wrote: > Hello List, > > Hardware: E5-Xeon 2697 v2, 32GB of RAM. > OSes tried: Xubuntu 14.04.1 LTS, CentOS 7, Ubuntu 12.04 LTS > Erlang versions the code was tried on: Erlang/OTP 17, R16, & R14 > > I have an issue where every time I use processes which contain within > themselves large data structures (Large deep learning single process > nodes), after just a minute or so Erlang core dumps. The amount of ram used > is only about 2GB, so it can't be the system running out of memory, and its > only using about 10 cores, since I'm only running 10 such processes. Now > the same code, the same program, the same platform, functions without a > problem when I keep these processes small (substantially smaller monolithic > NN-module in each process). Everything is written purely in Erlang (No NIFs > were involved in this particular NN code). > > What exactly is happening? is something running out of space? Can anyone > recommend what option during the Erlang startup I should perhaps modify to > alleviate the issue? > > There are no crushdump files that I can find, but I did get a core > backtrace produced during one of these crashes when I was running > erts-5.10.4, here is a partial paste of it: > > ccpp-2015-02-11-09\:18\:41-2273/core_backtrace: > { "signal": 11 > , "executable": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > , "stacktrace": > [ { "crash_thread": true > , "frames": > [ { "address": 5352736 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1158432 > , "function_name": "sweep_one_area" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5367589 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1173285 > , "function_name": "erts_garbage_collect" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5369251 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1174947 > , "function_name": "erts_gc_after_bif_call" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5871217 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1676913 > , "function_name": "nbif_3_gc_after_bif" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } ] > } > , { "frames": > [ { "address": 1101651978 > , "build_id_offset": 1101651978 > } ] > } > , { "frames": > [ { "address": 139994957883141 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 46853 > , "function_name": "pthread_cond_wait@@GLIBC_2.3.2" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 6128777 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1934473 > , "function_name": "ethr_cond_wait" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 4665919 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 471615 > , "function_name": "sys_msg_dispatcher_func" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 6134325 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1940021 > , "function_name": "thr_wrapper" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 139994957868531 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 32243 > , "function_name": "start_thread" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 139994952778157 > , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" > , "build_id_offset": 1008045 > , "function_name": "__clone" > , "file_name": "/lib64/libc.so.6" > } ] > } > , { "frames": > [ { "address": 139994957894237 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 57949 > , "function_name": "read" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 5741674 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1547370 > , "function_name": "signal_dispatcher_thread_func" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 6134325 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1940021 > , "function_name": "thr_wrapper" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 139994957868531 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 32243 > , "function_name": "start_thread" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 139994952778157 > , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" > , "build_id_offset": 1008045 > , "function_name": "__clone" > , "file_name": "/lib64/libc.so.6" > } ] > } > ... > > Thanks in advance for any suggestions and help, > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corticalcomputer@REDACTED Thu Feb 12 00:32:12 2015 From: corticalcomputer@REDACTED (Gene Sher) Date: Wed, 11 Feb 2015 18:32:12 -0500 Subject: [erlang-questions] Tracking down the reason for my Segmentation Fault (Core dump) problems. In-Reply-To: References: Message-ID: Though as noted it happened on various Erlang installations for me, the one I am currently using and on which I also get the Seg Fault is: Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:24:24] [async-threads:10] [hipe] [kernel-poll:false] On Wed, Feb 11, 2015 at 6:29 PM, Felix Gallo wrote: > What does it say when you type 'erl' at the command line? Example: > > Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:2:2] [async-threads:10] > [hipe] [kernel-poll:false] > > Eshell V6.0 (abort with ^G) > 1> > > On Wed, Feb 11, 2015 at 2:54 PM, Gene Sher > wrote: > >> Hello List, >> >> Hardware: E5-Xeon 2697 v2, 32GB of RAM. >> OSes tried: Xubuntu 14.04.1 LTS, CentOS 7, Ubuntu 12.04 LTS >> Erlang versions the code was tried on: Erlang/OTP 17, R16, & R14 >> >> I have an issue where every time I use processes which contain within >> themselves large data structures (Large deep learning single process >> nodes), after just a minute or so Erlang core dumps. The amount of ram used >> is only about 2GB, so it can't be the system running out of memory, and its >> only using about 10 cores, since I'm only running 10 such processes. Now >> the same code, the same program, the same platform, functions without a >> problem when I keep these processes small (substantially smaller monolithic >> NN-module in each process). Everything is written purely in Erlang (No NIFs >> were involved in this particular NN code). >> >> What exactly is happening? is something running out of space? Can anyone >> recommend what option during the Erlang startup I should perhaps modify to >> alleviate the issue? >> >> There are no crushdump files that I can find, but I did get a core >> backtrace produced during one of these crashes when I was running >> erts-5.10.4, here is a partial paste of it: >> >> ccpp-2015-02-11-09\:18\:41-2273/core_backtrace: >> { "signal": 11 >> , "executable": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> , "stacktrace": >> [ { "crash_thread": true >> , "frames": >> [ { "address": 5352736 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 1158432 >> , "function_name": "sweep_one_area" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } >> , { "address": 5367589 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 1173285 >> , "function_name": "erts_garbage_collect" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } >> , { "address": 5369251 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 1174947 >> , "function_name": "erts_gc_after_bif_call" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } >> , { "address": 5871217 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 1676913 >> , "function_name": "nbif_3_gc_after_bif" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } ] >> } >> , { "frames": >> [ { "address": 1101651978 >> , "build_id_offset": 1101651978 >> } ] >> } >> , { "frames": >> [ { "address": 139994957883141 >> , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" >> , "build_id_offset": 46853 >> , "function_name": "pthread_cond_wait@@GLIBC_2.3.2" >> , "file_name": "/lib64/libpthread.so.0" >> } >> , { "address": 6128777 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 1934473 >> , "function_name": "ethr_cond_wait" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } >> , { "address": 4665919 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 471615 >> , "function_name": "sys_msg_dispatcher_func" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } >> , { "address": 6134325 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 1940021 >> , "function_name": "thr_wrapper" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } >> , { "address": 139994957868531 >> , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" >> , "build_id_offset": 32243 >> , "function_name": "start_thread" >> , "file_name": "/lib64/libpthread.so.0" >> } >> , { "address": 139994952778157 >> , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" >> , "build_id_offset": 1008045 >> , "function_name": "__clone" >> , "file_name": "/lib64/libc.so.6" >> } ] >> } >> , { "frames": >> [ { "address": 139994957894237 >> , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" >> , "build_id_offset": 57949 >> , "function_name": "read" >> , "file_name": "/lib64/libpthread.so.0" >> } >> , { "address": 5741674 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 1547370 >> , "function_name": "signal_dispatcher_thread_func" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } >> , { "address": 6134325 >> , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" >> , "build_id_offset": 1940021 >> , "function_name": "thr_wrapper" >> , "file_name": >> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >> } >> , { "address": 139994957868531 >> , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" >> , "build_id_offset": 32243 >> , "function_name": "start_thread" >> , "file_name": "/lib64/libpthread.so.0" >> } >> , { "address": 139994952778157 >> , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" >> , "build_id_offset": 1008045 >> , "function_name": "__clone" >> , "file_name": "/lib64/libc.so.6" >> } ] >> } >> ... >> >> Thanks in advance for any suggestions and help, >> -Gene >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From felixgallo@REDACTED Thu Feb 12 00:43:57 2015 From: felixgallo@REDACTED (Felix Gallo) Date: Wed, 11 Feb 2015 15:43:57 -0800 Subject: [erlang-questions] Tracking down the reason for my Segmentation Fault (Core dump) problems. In-Reply-To: References: Message-ID: Was thinking perhaps it was a 32-bit installation, which can run out of memory in situations like that very quickly. Besides OS-level memory examination tools, the best (in my opinion) tools for diagnosing issues like this are eper (https://github.com/massemanet/eper) and recon (http://ferd.github.io/recon/). The redoubtable and inestimably worthy Mr. Hebert gives an excellent overview of the debugging process in situations just like this in his free ebook "Stuff Goes Bad: Erlang in Anger" (http://www.erlang-in-anger.com/). On Wed, Feb 11, 2015 at 3:32 PM, Gene Sher wrote: > Though as noted it happened on various Erlang installations for me, the > one I am currently using and on which I also get the Seg Fault is: > > Erlang/OTP 17 [erts-6.3] [source-f9282c6] [64-bit] [smp:24:24] > [async-threads:10] [hipe] [kernel-poll:false] > > > On Wed, Feb 11, 2015 at 6:29 PM, Felix Gallo wrote: > >> What does it say when you type 'erl' at the command line? Example: >> >> Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:2:2] [async-threads:10] >> [hipe] [kernel-poll:false] >> >> Eshell V6.0 (abort with ^G) >> 1> >> >> On Wed, Feb 11, 2015 at 2:54 PM, Gene Sher >> wrote: >> >>> Hello List, >>> >>> Hardware: E5-Xeon 2697 v2, 32GB of RAM. >>> OSes tried: Xubuntu 14.04.1 LTS, CentOS 7, Ubuntu 12.04 LTS >>> Erlang versions the code was tried on: Erlang/OTP 17, R16, & R14 >>> >>> I have an issue where every time I use processes which contain within >>> themselves large data structures (Large deep learning single process >>> nodes), after just a minute or so Erlang core dumps. The amount of ram used >>> is only about 2GB, so it can't be the system running out of memory, and its >>> only using about 10 cores, since I'm only running 10 such processes. Now >>> the same code, the same program, the same platform, functions without a >>> problem when I keep these processes small (substantially smaller monolithic >>> NN-module in each process). Everything is written purely in Erlang (No NIFs >>> were involved in this particular NN code). >>> >>> What exactly is happening? is something running out of space? Can anyone >>> recommend what option during the Erlang startup I should perhaps modify to >>> alleviate the issue? >>> >>> There are no crushdump files that I can find, but I did get a core >>> backtrace produced during one of these crashes when I was running >>> erts-5.10.4, here is a partial paste of it: >>> >>> ccpp-2015-02-11-09\:18\:41-2273/core_backtrace: >>> { "signal": 11 >>> , "executable": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> , "stacktrace": >>> [ { "crash_thread": true >>> , "frames": >>> [ { "address": 5352736 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 1158432 >>> , "function_name": "sweep_one_area" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } >>> , { "address": 5367589 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 1173285 >>> , "function_name": "erts_garbage_collect" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } >>> , { "address": 5369251 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 1174947 >>> , "function_name": "erts_gc_after_bif_call" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } >>> , { "address": 5871217 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 1676913 >>> , "function_name": "nbif_3_gc_after_bif" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } ] >>> } >>> , { "frames": >>> [ { "address": 1101651978 >>> , "build_id_offset": 1101651978 >>> } ] >>> } >>> , { "frames": >>> [ { "address": 139994957883141 >>> , "build_id": >>> "18562ee0363bc9bd7101610bd86469aa426d0c44" >>> , "build_id_offset": 46853 >>> , "function_name": "pthread_cond_wait@@GLIBC_2.3.2" >>> , "file_name": "/lib64/libpthread.so.0" >>> } >>> , { "address": 6128777 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 1934473 >>> , "function_name": "ethr_cond_wait" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } >>> , { "address": 4665919 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 471615 >>> , "function_name": "sys_msg_dispatcher_func" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } >>> , { "address": 6134325 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 1940021 >>> , "function_name": "thr_wrapper" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } >>> , { "address": 139994957868531 >>> , "build_id": >>> "18562ee0363bc9bd7101610bd86469aa426d0c44" >>> , "build_id_offset": 32243 >>> , "function_name": "start_thread" >>> , "file_name": "/lib64/libpthread.so.0" >>> } >>> , { "address": 139994952778157 >>> , "build_id": >>> "23d9f6f74c80c45a602094e5016f047bfc4d046c" >>> , "build_id_offset": 1008045 >>> , "function_name": "__clone" >>> , "file_name": "/lib64/libc.so.6" >>> } ] >>> } >>> , { "frames": >>> [ { "address": 139994957894237 >>> , "build_id": >>> "18562ee0363bc9bd7101610bd86469aa426d0c44" >>> , "build_id_offset": 57949 >>> , "function_name": "read" >>> , "file_name": "/lib64/libpthread.so.0" >>> } >>> , { "address": 5741674 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 1547370 >>> , "function_name": "signal_dispatcher_thread_func" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } >>> , { "address": 6134325 >>> , "build_id": >>> "69494bd95d056f5549e80b6fe507e55af574137f" >>> , "build_id_offset": 1940021 >>> , "function_name": "thr_wrapper" >>> , "file_name": >>> "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" >>> } >>> , { "address": 139994957868531 >>> , "build_id": >>> "18562ee0363bc9bd7101610bd86469aa426d0c44" >>> , "build_id_offset": 32243 >>> , "function_name": "start_thread" >>> , "file_name": "/lib64/libpthread.so.0" >>> } >>> , { "address": 139994952778157 >>> , "build_id": >>> "23d9f6f74c80c45a602094e5016f047bfc4d046c" >>> , "build_id_offset": 1008045 >>> , "function_name": "__clone" >>> , "file_name": "/lib64/libc.so.6" >>> } ] >>> } >>> ... >>> >>> Thanks in advance for any suggestions and help, >>> -Gene >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Thu Feb 12 01:58:33 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 12 Feb 2015 13:58:33 +1300 Subject: [erlang-questions] second try for understanding recursion In-Reply-To: <54D730DB.5080804@home.nl> References: <54D730DB.5080804@home.nl> Message-ID: On 8/02/2015, at 10:48 pm, Roelof Wobben wrote: > I did a portion of this exercise : > > Write a module boolean.erlthat takes logical expressions and Boolean values (represented as the atoms trueand false) and returns their Boolean result. Read P?lya's little book about mathematical problem solving, "How to Solve It". You will find copies on the Web these days, see https://notendur.hi.is/hei2/teaching/Polya_HowToSolveIt.pdf for one. He speaks of four phases: * UNDERSTANDING THE PROBLEM * DEVISING A PLAN * CARRYING OUT THE PLAN * LOOKING BACK (By the way, it's a strange experience looking at the "Dictionary of Heuristic" in this book with "Design Patterns" eyes. He had a pattern language for problem solving before anyone coined the term "pattern language"...) Page 214 has the entry WHAT IS THE UNKNOWN? - What is required? - What do you want? - What are you supposed to seek? * What are the data? - What is given? - What [do you already have]? * What is the condition? - By what condition is the unknown linked to the problem? ... The questions are of the greatest importance... The single most important skill you need to develop at this point is UNDERSTANDING THE PROBLEM AND STATING IT CLEARLY. In this case, what does "takes logical expressions" mean? (Oh, and what is the distinction between "logical" expressions and "Boolean" values?) The way *I* read it, "taking logical expressions" means ACCEPTING AS ARGUMENTS DATA STRUCTURES THAT ARE TREES REPRESENTING BOOLEAN EXPRESSIONS. So we need to start by saying how that will be done, and I offer + false + true + {not,E1} where E1 is a logical expression + {and,E1,E2} where E1, E2 are logical expressions + {or,E1,E2} where E1, E2 are logical expressions and that data type pretty much *forces* the following structural recursion: eval(false) -> false; eval(true) -> true; eval({not,E1}) -> case eval(E1) of true -> false ; false -> true end; eval({and,E1,E2}) -> case eval(E1) of true -> eval(E2) ; false -> false end; eval({or,E1,E2}) -> case eval(E1) of true -> true ; false -> eval(E2) end. > The functions > you write should include b_not/1, b_and/2, b_or/2, and b_nand/2. You should not use > the logical constructs and, or, and not, but instead use pattern matching to achieve your > goal. With that in hand, we can write b_not(E1) -> eval({not,E1}). b_and(E1, E2) -> eval({and,E1,E2}). b_or(E1, E2) -> eval({or,E1,E2}). b_nand(E1, E2) -> eval({not,{and,E1,E2}}). If that is _not_ what the problem is about, what _does_ "take logical expressions" mean, and where does recursion come into it? By the way, supposing that we are just working with false and true, that is, with logical CONSTANTS, not logical EXPRESSIONS, we can meet the letter of the specification easily while violating its spirit: b_and(V1, V2) -> V1 andalso V2. b_or(V1, V2) -> V1 orelse V2. We can also meet the letter and violate the spirit another way: b_and(V1, V2) when V1 -> V2; b_and(_, _ ) -> false. b_or(V1, _ ) when V1 -> true; b_or(_, V2) -> V2. I don't really expect you to understand all these solutions. What I very much hope you will understand is that WHAT COUNTS AS A SOLUTION DEPENDS ON WHAT THE PROBLEM IS so that IT IS OF THE GREATEST IMPORTANCE TO UNDERSTAND WHAT THE PROBLEM *IS*. And not just to understand, but to *write down*. > -module(boolean). > > -export([b_not/1]). > > % if a empty string is given , the answer will be a empty string. > b_not('') -> > ''; > The two values you are supposed to work with are 'false' and 'true'. There is nothing in the problem specification you gave us, such as it is and what there is of it, that requires *any* particular behaviour for the empty atom ('' is NOT a string). This clause is literally worse than useless. Not only does it contribute nothing to a correct solution of the problem, if the b_not/1 function _should_ happen to be called incorrectly, the error might be propagated instead of being caught. > % is false is given, the answer will be true. This is a junk comment. It just paraphrases the code. > b_not(false) -> > true; > > % is true is given, the answer will be false This is a junk comment. It just paraphrases the code. > b_not(true) -> > false. The code tells us what DOES happen. Comments ought to tell us what IS SUPPOSED TO happen. Or the reason. So a comment like % When is_boolean(V), b_not(V) should equal (not V). % The exercise is to do this with pattern matching only. tells us what is supposed to happen and why. From ok@REDACTED Thu Feb 12 02:58:48 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 12 Feb 2015 14:58:48 +1300 Subject: [erlang-questions] is this a well written function In-Reply-To: <54DB0098.8000702@gmail.com> References: <54D88028.8000802@home.nl> <54DB0098.8000702@gmail.com> Message-ID: On 11/02/2015, at 8:11 pm, Martin Koroudjiev wrote: > >> sum(N) when is_integer(N), N >= 0 -> >> (N * (N+1)) // 2. >> > > Should be with a single forward slash. Sorry. I use too many programming languages, and notations for integer division are just pointlessly diverse. (And since Erlang syntax was copied from Prolog, it is NOT helpful that it doesn't use Prolog's integer division operator, see http://en.wiktionary.org/wiki/faux_ami .) NO, this should NOT be with a forward slash. It should be sum(N) when is_integer(N), N >= 0 -> (N * (N + 1)) div 2. % ^^^ > Also the OP should know that this function will return a float. Not if implemented correctly it won't. Integer division can be missing in AWK and Perl and APL (?x?y isn't really the same) / in Fortran, and the C family (/ is used for fixed division in PL/I, but 25+1/3 raises FIXEDOVERFLOW) \ MUMPS (officially M these days), also MathWorld ? in Algol 60 and Algol 68 (where it's also OVER) div in the Pascal family and SML `div` in Haskell // in Smalltalk, Prolog, Eiffel, and Python 2.2 and later quo: in Smalltalk (which has 2 of the 5 candidates for what "integer division" should mean) %/% in the S family (including R). (quotient x y) in Scheme (floor x y), (truncate x y) (ceiling x y) (round x y) in Lisp A programming language I used to like a lot used X / Y to mean X ++ "/" ++ Y. From ok@REDACTED Thu Feb 12 03:25:02 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Thu, 12 Feb 2015 15:25:02 +1300 Subject: [erlang-questions] is this a well written function In-Reply-To: <54DB089D.50900@home.nl> References: <54D88028.8000802@home.nl> <54DB089D.50900@home.nl> Message-ID: <5E88B594-CE27-44B2-A2C1-B6E57086FEAB@cs.otago.ac.nz> On 11/02/2015, at 8:45 pm, Roelof Wobben wrote: > -export([display_numbers/1]). > > %% displays(N) displays the numbers from 1,2,...+N when N is a non-negative integer. > %% It is not defined for other arguments. > %% When N is a non-negative number, a helper function is called so it prints out > %% the numbers in the right order. This is a exercise from the Erlang Programming book > %% where I have to practice side-effects. The comment disagrees with the code. The comment says the function call is 'displays(_)',' but the code says it is 'display_numbers(_)'. The comment disagrees with the code. The comment says "when N is a NON-NEGATIVE INTEGER", but the code insists on a STRICTLY POSITIVE number of any kind. So the comment would accept 0 and reject 1.2, while the code rejects 0 and accepts 1.2. > display_numbers(Number) when Number > 0 -> > display_numbers_loop(Number, 1). You would do better to stick with the comment, and to count UP from 0, so that the control argument actually means something: it counts how many numbers already printed. Also, control arguments are conventionally written first. display_numbers(N) when is_integer(N), N >= 0 -> % 1; A,B display_numbers_loop(0, N). % 2; C % In display_numbers_loop(N0, N), N is how many numbers % we want to print altogether, and N0 is how many % numbers we have already printed. display_numbers_loop(N, N) -> % 3; C ok; % 4; F display_numbers_loop(N0, N) -> % 5; N1 = N0 + 1, % 6; C,D io:format("Number: ~p~n", [N1]), % 7; D display_numbers_loop(N1, N). % 8; > %% When the control argument)(second argument) is equal to the number > %% the user has given, the end is reached and the last number is printed > display_numbers_loop(Number, Number) -> > io:format("Number:~p~n",[Number]); > > %% When the contro argument(second argument) is not equal to the number > %5 the user has given the control argument is increased by one and the > %% display_numbers_loop function is called again with the new arguments. > display_numbers_loop(Number, Current) -> > io:format("Number:~p~n",[Current]), > display_numbers_loop(Number, Current +1 ). You have two copies of the io:format/2 call. That should set off alarm bells in your mind. (Martin Fowler uses the term "code smells".) If you want to do "something" N times, then "something" should normally be written once and only once. Think about it: it's pretty ugly to omit the space after the colon in the format. We only want to have to fix that just once. If it's written twice, it's way too easy to fix one copy and not the other. If you were doing this in C, you would have void display_numbers(int N) { // 1; A assert(N >= 0); // 1; B for (int I = 0; I < N; I++) { // 2,3,5,8; C printf("Number: %d\n", I+1); // 7; D } // 8; E } // 4; F I've numbered the Erlang lines with integers and the C lines with letters to show the correspondence of the parts. Oh yeah, one more thing. Who is "the user"? A "user" is a human being, but functions are usually called by other functions. Why did I start the loop at 0, not 1? Generally speaking, counting "what have I already done" seems to result in many fewer errors than "what is the next thing to do". I originally learned Fortran and COBOL and Algol where the index origin is (Fortran, COBOL) or is conventionally (Algol) 1. In languages like C and Lisp where the index origin is 0, I make so many fewer off-by-one errors that it just is not funny. (Yes, I do find it regrettable that Erlang indexes tuples from 1.) To be honest, Smalltalk's use of index origin 1 is a constant pain in the (your choice of body part). You might want to read "Why numbering should start at zero." https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html Oh double yeah. There is a general translation from a C 'for' loop to a functional (tail) recursion. f(...) { g(...); for (T x = i(...); p(x, ...); x = u(x, ...) { b(x, ...); } c(...); } turns into f(...) -> g(...), f_loop(i(...), ...). f_loop(X, ...) when p(X, ...) -> b(X, ...), f_loop(u(X, ...), ...); f_loop(_, ...) -> c(...). Things get a little more tricky when p(X, ...) doesn't fit the restrictions of a guard, and I've said nothing about variables being updated in the loop, but this is how you start. In a strict functional language with strong static types, like SML, I'd expect the C version and the functional version to result in pretty much the same machine code. From r.wobben@REDACTED Thu Feb 12 08:03:22 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Thu, 12 Feb 2015 08:03:22 +0100 Subject: [erlang-questions] is this a well written function In-Reply-To: <5E88B594-CE27-44B2-A2C1-B6E57086FEAB@cs.otago.ac.nz> References: <54D88028.8000802@home.nl> <54DB089D.50900@home.nl> <5E88B594-CE27-44B2-A2C1-B6E57086FEAB@cs.otago.ac.nz> Message-ID: <54DC503A.60704@home.nl> Richard A. O'Keefe schreef op 12-2-2015 om 3:25: > On 11/02/2015, at 8:45 pm, Roelof Wobben wrote: >> -export([display_numbers/1]). >> >> %% displays(N) displays the numbers from 1,2,...+N when N is a non-negative integer. >> %% It is not defined for other arguments. >> %% When N is a non-negative number, a helper function is called so it prints out >> %% the numbers in the right order. This is a exercise from the Erlang Programming book >> %% where I have to practice side-effects. > The comment disagrees with the code. > The comment says the function call is 'displays(_)',' > but the code says it is 'display_numbers(_)'. > > The comment disagrees with the code. > The comment says "when N is a NON-NEGATIVE INTEGER", > but the code insists on a STRICTLY POSITIVE number of > any kind. So the comment would accept 0 and reject 1.2, > while the code rejects 0 and accepts 1.2. > >> display_numbers(Number) when Number > 0 -> >> display_numbers_loop(Number, 1). > You would do better to stick with the comment, > and to count UP from 0, so that the control argument > actually means something: it counts how many numbers > already printed. Also, control arguments are > conventionally written first. > > display_numbers(N) when is_integer(N), N >= 0 -> % 1; A,B > display_numbers_loop(0, N). % 2; C > > % In display_numbers_loop(N0, N), N is how many numbers > % we want to print altogether, and N0 is how many > % numbers we have already printed. > > display_numbers_loop(N, N) -> % 3; C > ok; % 4; F > display_numbers_loop(N0, N) -> % 5; > N1 = N0 + 1, % 6; C,D > io:format("Number: ~p~n", [N1]), % 7; D > display_numbers_loop(N1, N). % 8; > > Thanks for all the remarks. I changed it all but one remark about your code ; When I do N1 = N0 + 1 then I get a error because N1 is imutable and cannot be changed. So the new code will be : -module(side_effects). -export([display_numbers/1]). %% display_numbers(N) displays the numbers from 1,2,...+N when N is a non-negative integer. %% It is not defined for other arguments. %% When N is a non-negative number, a helper function is called so it prints out %% the numbers in the right order. This is a exercise from the Erlang Programming book %% where I have to practice side-effects. display_numbers(Number) when is_integer(Number), Number > 0 -> display_numbers_loop(0, Number ). %% When the control argument)(second argument) is equal to the number %% the user has given, the end is reached and the last number is printed display_numbers_loop(Number, Number) -> ok; %% When the contro argument(second argument) is not equal to the number %% the user has given the control argument is increased by one and the %% display_numbers_loop function is called again with the new arguments. display_numbers_loop(Current, Number) -> io:format("Number:~p~n",[Current + 1]), display_numbers_loop(Current +1, Number ). Roelof From lukas@REDACTED Thu Feb 12 09:52:05 2015 From: lukas@REDACTED (Lukas Larsson) Date: Thu, 12 Feb 2015 09:52:05 +0100 Subject: [erlang-questions] Tracking down the reason for my Segmentation Fault (Core dump) problems. In-Reply-To: References: Message-ID: Hello Gene, Without having a full core file, I cannot do much more than guess as to what might be wrong. What most likely is happened is that something somehow got corrupted on the heap of that process. Normally I would blame a badly written NIF/linked-in driver, but as you say you don't have anything like that, then we can rule that out. Without more information (i.e. a full core file) it is extremely hard to tell what has gone wrong. This is most likely not due to the VM running out of memory, you would see another error if that were to happen. Lukas On Wed, Feb 11, 2015 at 11:54 PM, Gene Sher wrote: > Hello List, > > Hardware: E5-Xeon 2697 v2, 32GB of RAM. > OSes tried: Xubuntu 14.04.1 LTS, CentOS 7, Ubuntu 12.04 LTS > Erlang versions the code was tried on: Erlang/OTP 17, R16, & R14 > > I have an issue where every time I use processes which contain within > themselves large data structures (Large deep learning single process > nodes), after just a minute or so Erlang core dumps. The amount of ram used > is only about 2GB, so it can't be the system running out of memory, and its > only using about 10 cores, since I'm only running 10 such processes. Now > the same code, the same program, the same platform, functions without a > problem when I keep these processes small (substantially smaller monolithic > NN-module in each process). Everything is written purely in Erlang (No NIFs > were involved in this particular NN code). > > What exactly is happening? is something running out of space? Can anyone > recommend what option during the Erlang startup I should perhaps modify to > alleviate the issue? > > There are no crushdump files that I can find, but I did get a core > backtrace produced during one of these crashes when I was running > erts-5.10.4, here is a partial paste of it: > > ccpp-2015-02-11-09\:18\:41-2273/core_backtrace: > { "signal": 11 > , "executable": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > , "stacktrace": > [ { "crash_thread": true > , "frames": > [ { "address": 5352736 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1158432 > , "function_name": "sweep_one_area" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5367589 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1173285 > , "function_name": "erts_garbage_collect" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5369251 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1174947 > , "function_name": "erts_gc_after_bif_call" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5871217 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1676913 > , "function_name": "nbif_3_gc_after_bif" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } ] > } > , { "frames": > [ { "address": 1101651978 > , "build_id_offset": 1101651978 > } ] > } > , { "frames": > [ { "address": 139994957883141 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 46853 > , "function_name": "pthread_cond_wait@@GLIBC_2.3.2" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 6128777 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1934473 > , "function_name": "ethr_cond_wait" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 4665919 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 471615 > , "function_name": "sys_msg_dispatcher_func" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 6134325 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1940021 > , "function_name": "thr_wrapper" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 139994957868531 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 32243 > , "function_name": "start_thread" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 139994952778157 > , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" > , "build_id_offset": 1008045 > , "function_name": "__clone" > , "file_name": "/lib64/libc.so.6" > } ] > } > , { "frames": > [ { "address": 139994957894237 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 57949 > , "function_name": "read" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 5741674 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1547370 > , "function_name": "signal_dispatcher_thread_func" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 6134325 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1940021 > , "function_name": "thr_wrapper" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 139994957868531 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 32243 > , "function_name": "start_thread" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 139994952778157 > , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" > , "build_id_offset": 1008045 > , "function_name": "__clone" > , "file_name": "/lib64/libc.so.6" > } ] > } > ... > > Thanks in advance for any suggestions and help, > -Gene > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From p.wycisk@REDACTED Thu Feb 12 10:36:48 2015 From: p.wycisk@REDACTED (=?UTF-8?Q?Przemys=C5=82aw_Wycisk?=) Date: Thu, 12 Feb 2015 10:36:48 +0100 Subject: [erlang-questions] erlang http tcp_closed problem In-Reply-To: References: Message-ID: The reason of that behaviour was option packet_size on socket. Default set of this option ({packet_size, 0}) should mean no size (line size in http) limit shouldn't it?, but packets were dropped because of large cookie header. I consider it as a bug, and also i think that if line size limit in http socket occurs i should get http_error instead of tcp_closed, it's quite confusing. On Sun, Feb 8, 2015 at 7:25 PM, Przemys?aw Wycisk wrote: > I've got problem with using erlang active http socket. > > I receive msgs like that: > > ok = inet:setopts(Sock,[{active, true}]), > receive > {http, Sock, {http_request, HttpMethod, {abs_path, Path}, _HttpVersion}} -> > Headers = getHeaders(Sock), > %more code > > and then headers like that: > > getHeaders(Sock, Headers) -> > receive > {http, Sock, {http_header, _Num, 'Content-Length', _, Value}} -> > NewHeaders = Headers#'headers'{contentLength = Value}, > getHeaders(Sock, NewHeaders); > {http, Sock, {http_header, _Num, 'Host', _, Value}} -> > NewHeaders = Headers#'headers'{host = Value}, > getHeaders(Sock, NewHeaders); > {http, Sock, {http_header, _Num, 'User-Agent', _, Value}} -> > NewHeaders = Headers#'headers'{userAgent = Value}, > getHeaders(Sock, NewHeaders); > %more headers here > % > > {http, Sock, {http_error, Error}} -> > ?LOG_INFO("protocol", "http returned error with reason:~p~n", [Error]), > exit(normal); > {http, Sock, http_eoh} -> > Headers; > {tcp_closed, Sock} -> % > ?LOG_INFO("connection", "Socket ~w closed by client", [Sock]), > exit(normal); > _Else -> > getHeaders(Sock, Headers) > end. > > > Normally it works fine, packets and headers are received from browser and > everyone is happy, but there is a case, when a browser sends a request, and > then i get "tcp_closed" in place where is placed, in the middle of > receiving headers. > > This behaviour is strange for me, because it never happens in incognito > mode. That could mean that bowsers cache is involved in the problem, but > how? > > Anyone had the same problem? Anyone could help? I would be grateful. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From sverker.eriksson@REDACTED Thu Feb 12 14:43:14 2015 From: sverker.eriksson@REDACTED (Sverker Eriksson) Date: Thu, 12 Feb 2015 14:43:14 +0100 Subject: [erlang-questions] Tracking down the reason for my Segmentation Fault (Core dump) problems. In-Reply-To: References: Message-ID: <54DCADF2.6000006@erix.ericsson.se> This looks like it's HiPE related. The function nbif_3_gc_after_bif (found in your backtrace) is only called when hipe compiled code calls a BIF that trigger a garbage collection. I'll bet you do not get this if you run pure beam. /Sverker On 02/11/2015 11:54 PM, Gene Sher wrote: > Hello List, > > Hardware: E5-Xeon 2697 v2, 32GB of RAM. > OSes tried: Xubuntu 14.04.1 LTS, CentOS 7, Ubuntu 12.04 LTS > Erlang versions the code was tried on: Erlang/OTP 17, R16, & R14 > > I have an issue where every time I use processes which contain within > themselves large data structures (Large deep learning single process > nodes), after just a minute or so Erlang core dumps. The amount of ram used > is only about 2GB, so it can't be the system running out of memory, and its > only using about 10 cores, since I'm only running 10 such processes. Now > the same code, the same program, the same platform, functions without a > problem when I keep these processes small (substantially smaller monolithic > NN-module in each process). Everything is written purely in Erlang (No NIFs > were involved in this particular NN code). > > What exactly is happening? is something running out of space? Can anyone > recommend what option during the Erlang startup I should perhaps modify to > alleviate the issue? > > There are no crushdump files that I can find, but I did get a core > backtrace produced during one of these crashes when I was running > erts-5.10.4, here is a partial paste of it: > > ccpp-2015-02-11-09\:18\:41-2273/core_backtrace: > { "signal": 11 > , "executable": "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > , "stacktrace": > [ { "crash_thread": true > , "frames": > [ { "address": 5352736 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1158432 > , "function_name": "sweep_one_area" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5367589 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1173285 > , "function_name": "erts_garbage_collect" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5369251 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1174947 > , "function_name": "erts_gc_after_bif_call" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 5871217 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1676913 > , "function_name": "nbif_3_gc_after_bif" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } ] > } > , { "frames": > [ { "address": 1101651978 > , "build_id_offset": 1101651978 > } ] > } > , { "frames": > [ { "address": 139994957883141 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 46853 > , "function_name": "pthread_cond_wait@@GLIBC_2.3.2" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 6128777 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1934473 > , "function_name": "ethr_cond_wait" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 4665919 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 471615 > , "function_name": "sys_msg_dispatcher_func" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 6134325 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1940021 > , "function_name": "thr_wrapper" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 139994957868531 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 32243 > , "function_name": "start_thread" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 139994952778157 > , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" > , "build_id_offset": 1008045 > , "function_name": "__clone" > , "file_name": "/lib64/libc.so.6" > } ] > } > , { "frames": > [ { "address": 139994957894237 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 57949 > , "function_name": "read" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 5741674 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1547370 > , "function_name": "signal_dispatcher_thread_func" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 6134325 > , "build_id": "69494bd95d056f5549e80b6fe507e55af574137f" > , "build_id_offset": 1940021 > , "function_name": "thr_wrapper" > , "file_name": > "/usr/lib64/erlang/erts-5.10.4/bin/beam.smp" > } > , { "address": 139994957868531 > , "build_id": "18562ee0363bc9bd7101610bd86469aa426d0c44" > , "build_id_offset": 32243 > , "function_name": "start_thread" > , "file_name": "/lib64/libpthread.so.0" > } > , { "address": 139994952778157 > , "build_id": "23d9f6f74c80c45a602094e5016f047bfc4d046c" > , "build_id_offset": 1008045 > , "function_name": "__clone" > , "file_name": "/lib64/libc.so.6" > } ] > } > ... > > Thanks in advance for any suggestions and help, > -Gene > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben@REDACTED Thu Feb 12 15:33:58 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Thu, 12 Feb 2015 15:33:58 +0100 Subject: [erlang-questions] why does the guard not working Message-ID: <54DCB9D6.7040006@home.nl> Hello, I have this code : -module(side_effects). -export([display_numbers/1]). %% display_numbers(N) displays the numbers from 1,2,...+N when N is a non-negative integer. %% It is not defined for other arguments. %% When N is a non-negative number, a helper function is called so it prints out %% the numbers in the right order. This is a exercise from the Erlang Programming book %% where I have to practice side-effects. display_numbers(Number) when is_integer(Number), Number > 0 -> display_numbers_loop(0, Number ). %% When the control argument)(second argument) is equal to the number %% the user has given, the end is reached and the last number is printed display_numbers_loop(Number, Number) -> ok; %% When the contro argument(second argument) is not equal to the number %% and the Current number is even, %% The control argument is increased by one and the %% display_numbers_loop function is called again with the new arguments. display_numbers_loop(Current, Number) when Current / 2 == 0 -> io:format("Number:~p~n",[Current + 1]), display_numbers_loop(Current +1, Number ); %% When the contro argument(second argument) is not equal to the number %% and the Current number is not even, %% The control argument is increased by one and the %% display_numbers_loop function is called again with the new arguments. display_numbers_loop(Current, Number) when Current / 2 /= 0 -> io:format("Number:~p~n",[Current + 1]), display_numbers_loop(Current +1, Number ). but when I do side_effects(10) I see all the numbers so I wonder why the when is not working ? Roelof From bengt.kleberg@REDACTED Thu Feb 12 15:38:27 2015 From: bengt.kleberg@REDACTED (Bengt Kleberg) Date: Thu, 12 Feb 2015 15:38:27 +0100 Subject: [erlang-questions] why does the guard not working In-Reply-To: <54DCB9D6.7040006@home.nl> References: <54DCB9D6.7040006@home.nl> Message-ID: <54DCBAE3.1060405@ericsson.com> Have you tested Current / 2 == 0 with some values for Current? It is only true when Current is 0. The erlang shell is your friend for simple tests like this. bengt On 02/12/2015 03:33 PM, Roelof Wobben wrote: > Hello, > > I have this code : > > -module(side_effects). > > -export([display_numbers/1]). > > %% display_numbers(N) displays the numbers from 1,2,...+N when N is > a non-negative integer. > %% It is not defined for other arguments. > %% When N is a non-negative number, a helper function is called so it > prints out > %% the numbers in the right order. This is a exercise from the Erlang > Programming book > %% where I have to practice side-effects. > display_numbers(Number) when is_integer(Number), Number > 0 -> > display_numbers_loop(0, Number ). > > %% When the control argument)(second argument) is equal to the number > %% the user has given, the end is reached and the last number is printed > display_numbers_loop(Number, Number) -> > ok; > > %% When the contro argument(second argument) is not equal to the number > %% and the Current number is even, > %% The control argument is increased by one and the > %% display_numbers_loop function is called again with the new arguments. > display_numbers_loop(Current, Number) when Current / 2 == 0 -> > io:format("Number:~p~n",[Current + 1]), > display_numbers_loop(Current +1, Number ); > > %% When the contro argument(second argument) is not equal to the number > %% and the Current number is not even, > %% The control argument is increased by one and the > %% display_numbers_loop function is called again with the new arguments. > display_numbers_loop(Current, Number) when Current / 2 /= 0 -> > io:format("Number:~p~n",[Current + 1]), > display_numbers_loop(Current +1, Number ). > > but when I do side_effects(10) I see all the numbers so I wonder why > the when is not working ? > > Roelof > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From r.wobben@REDACTED Thu Feb 12 15:51:02 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Thu, 12 Feb 2015 15:51:02 +0100 Subject: [erlang-questions] why does the guard not working In-Reply-To: <54DCBAE3.1060405@ericsson.com> References: <54DCB9D6.7040006@home.nl> <54DCBAE3.1060405@ericsson.com> Message-ID: <54DCBDD6.9060707@home.nl> Thanks , Stupid mistake I had to use rem. Now i have this : -module(side_effects). -export([display_numbers/1]). %% display_numbers(N) displays the numbers from 1,2,...+N when N is a non-negative integer. %% It is not defined for other arguments. %% When N is a non-negative number, a helper function is called so it prints out %% the numbers in the right order. This is a exercise from the Erlang Programming book %% where I have to practice side-effects. display_numbers(Number) when is_integer(Number), Number > 0 -> display_numbers_loop(0, Number ). %% When the control argument)(second argument) is equal to the number %% the user has given, the end is reached and the last number is printed display_numbers_loop(Number, Number) -> ok; %% When the contro argument(second argument) is not equal to the number %% and the Current number is even, %% The control argument is increased by one and the %% display_numbers_loop function is called again with the new arguments. display_numbers_loop(Current, Number) when Current rem 2 == 0 -> io:format("Number:~p~n",[Current + 1]), display_numbers_loop(Current +1, Number ); %% When the contro argument(second argument) is not equal to the number %% and the Current number is not even, %% The control argument is increased by one and the %% display_numbers_loop function is called again with the new arguments. display_numbers_loop(Current, Number) when Current rem 2 /= 0 -> display_numbers_loop(Current +1, Number ). but now I see only the odd numbers which I find wierd because I say when Current rem 2 ==0 and that true for even numbers. So then the io can be found. Roelof Bengt Kleberg schreef op 12-2-2015 om 15:38: > Have you tested > Current / 2 == 0 > with some values for Current? > It is only true when Current is 0. > > The erlang shell is your friend for simple tests like this. > > > bengt > > On 02/12/2015 03:33 PM, Roelof Wobben wrote: >> Hello, >> >> I have this code : >> >> -module(side_effects). >> >> -export([display_numbers/1]). >> >> %% display_numbers(N) displays the numbers from 1,2,...+N when N is >> a non-negative integer. >> %% It is not defined for other arguments. >> %% When N is a non-negative number, a helper function is called so >> it prints out >> %% the numbers in the right order. This is a exercise from the >> Erlang Programming book >> %% where I have to practice side-effects. >> display_numbers(Number) when is_integer(Number), Number > 0 -> >> display_numbers_loop(0, Number ). >> >> %% When the control argument)(second argument) is equal to the number >> %% the user has given, the end is reached and the last number is >> printed >> display_numbers_loop(Number, Number) -> >> ok; >> >> %% When the contro argument(second argument) is not equal to the number >> %% and the Current number is even, >> %% The control argument is increased by one and the >> %% display_numbers_loop function is called again with the new >> arguments. >> display_numbers_loop(Current, Number) when Current / 2 == 0 -> >> io:format("Number:~p~n",[Current + 1]), >> display_numbers_loop(Current +1, Number ); >> >> %% When the contro argument(second argument) is not equal to the number >> %% and the Current number is not even, >> %% The control argument is increased by one and the >> %% display_numbers_loop function is called again with the new >> arguments. >> display_numbers_loop(Current, Number) when Current / 2 /= 0 -> >> io:format("Number:~p~n",[Current + 1]), >> display_numbers_loop(Current +1, Number ). >> >> but when I do side_effects(10) I see all the numbers so I wonder why >> the when is not working ? >> >> Roelof >> >> _______________________________________________ >> 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 raimo+erlang-questions@REDACTED Thu Feb 12 16:15:00 2015 From: raimo+erlang-questions@REDACTED (Raimo Niskanen) Date: Thu, 12 Feb 2015 16:15:00 +0100 Subject: [erlang-questions] More Information: snmpm:register_agent/3 suddenly stopped working! In-Reply-To: References: Message-ID: <20150212151500.GA20219@erix.ericsson.se> On Tue, Feb 10, 2015 at 11:36:43PM -0500, jim rosenblum wrote: > Sorry, I said it backwards in my last email. It works on 17.1 does not work > on 17.4. > > More information: > > on 17.1 CentOS release 6.2 > > snmpm:register_agent(snmp_manager,"Hope", [{engine_id, > "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"},{port,161}, > {tdomain,transportDomainUdpIpv4},{sec_level, noAuthNoPriv},{sec_name, > "initial"},{version, v2},{timeout,1000}]). > > ok > > on 17.4 CentOS release 5.5 -- used to work before I upgraded to 17.4 > snmpm:register_agent(snmp_manager,"Hope", [{engine_id, > "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"},{port,161}, > {tdomain,transportDomainUdpIpv4},{sec_level, noAuthNoPriv},{sec_name, > "initial"},{version, v2},{timeout,1000}]). > > {error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} Most of the address handling code in SNMP was rewritten to handle IPv6, maybe it was after 17.1, my memory is weak. Anyway, I did not see that an address in string format was valid in the address parsing functions so I may have destroyed that possibility... An address should be an Erlang style address tuple: {10,7,42,11} or an SNMP style byte list [10,7,42,11]. Is this way of specifying the address important to you, and if so should an address "host.domain" also be allowed and looked up, or is it just the parseable strings that are needed? If this is important enough it can probably be fixed. / Raimo Niskanen, Erlang/OTP > > > On Tue, Feb 10, 2015 at 10:40 PM, jim rosenblum > > wrote: > > > >> Folks, > >> > >> I have an application that uses snmp that used to work and all of a > >> sudden doesn't - I did upgrade from 17.1 to 17.4 - but other than that > >> nothing has changed that I know of. I am having trouble down-grading, so I > >> cannot confirm that the upgrade is the culprit. > >> > >> When I do the following from a machine with IP address 10.6.81.19 > >> 1> snmpm:register_agent(hope,"Hope", [{engine_id, > >> "mgrEngine"},{community,"CLSENTRY"},{address, "10.7.42.11"}]). > >> > >> I get > >> {error,{bad_address,{snmpUDPDomain,"10.7.42.11"}}} > >> > >> I have an appropriate snmpd.conf on 10.7.42.11 that has > >> > >> com2sec sentrysrv 10.6.81.19/32 CLSENTRY > >> group CLROGroup v2c sentrysrv > >> view all included .1 80 > >> access CLROGroup "" v2c noauth exact all none none > >> > >> adding {tdomain, transportDomainUdpIpv4} to the option list results in > >> the, essentially, same error: > >> > >> {error,{bad_address,{{error,{bad_address,{transportDomainUdpIpv4,"10.7.42.11"}}} > >> > >> > >> Both machines can ping each other. The snmpd daemon is running on .11, I > >> have tried all kinds of additional options (port, etc.), but cannot get it > >> to work > >> > >> This is *killing* me, can anyone point out what stupid thing I am doing > >> wrong? > >> > >> > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- / Raimo Niskanen, Erlang/OTP, Ericsson AB From eriksoe@REDACTED Thu Feb 12 17:47:34 2015 From: eriksoe@REDACTED (=?UTF-8?Q?Erik_S=C3=B8e_S=C3=B8rensen?=) Date: Thu, 12 Feb 2015 17:47:34 +0100 Subject: [erlang-questions] why does the guard not working In-Reply-To: <54DCBDD6.9060707@home.nl> References: <54DCB9D6.7040006@home.nl> <54DCBAE3.1060405@ericsson.com> <54DCBDD6.9060707@home.nl> Message-ID: Not so odd - look at the next line, at what you're telling it to print (it's not Current). Den 12/02/2015 15.51 skrev "Roelof Wobben" : > Thanks , > > Stupid mistake I had to use rem. > > Now i have this : > > -module(side_effects). > > -export([display_numbers/1]). > > %% display_numbers(N) displays the numbers from 1,2,...+N when N is a > non-negative integer. > %% It is not defined for other arguments. > %% When N is a non-negative number, a helper function is called so it > prints out > %% the numbers in the right order. This is a exercise from the Erlang > Programming book > %% where I have to practice side-effects. > display_numbers(Number) when is_integer(Number), Number > 0 -> > display_numbers_loop(0, Number ). > > %% When the control argument)(second argument) is equal to the number > %% the user has given, the end is reached and the last number is printed > display_numbers_loop(Number, Number) -> > ok; > > %% When the contro argument(second argument) is not equal to the number > %% and the Current number is even, > %% The control argument is increased by one and the > %% display_numbers_loop function is called again with the new arguments. > display_numbers_loop(Current, Number) when Current rem 2 == 0 -> > io:format("Number:~p~n",[Current + 1]), > display_numbers_loop(Current +1, Number ); > > %% When the contro argument(second argument) is not equal to the number > %% and the Current number is not even, > %% The control argument is increased by one and the > %% display_numbers_loop function is called again with the new arguments. > display_numbers_loop(Current, Number) when Current rem 2 /= 0 -> > display_numbers_loop(Current +1, Number ). > > but now I see only the odd numbers which I find wierd because I say when > Current rem 2 ==0 and that true for even numbers. > So then the io can be found. > > Roelof > > > > Bengt Kleberg schreef op 12-2-2015 om 15:38: > >> Have you tested >> Current / 2 == 0 >> with some values for Current? >> It is only true when Current is 0. >> >> The erlang shell is your friend for simple tests like this. >> >> >> bengt >> >> On 02/12/2015 03:33 PM, Roelof Wobben wrote: >> >>> Hello, >>> >>> I have this code : >>> >>> -module(side_effects). >>> >>> -export([display_numbers/1]). >>> >>> %% display_numbers(N) displays the numbers from 1,2,...+N when N is a >>> non-negative integer. >>> %% It is not defined for other arguments. >>> %% When N is a non-negative number, a helper function is called so it >>> prints out >>> %% the numbers in the right order. This is a exercise from the Erlang >>> Programming book >>> %% where I have to practice side-effects. >>> display_numbers(Number) when is_integer(Number), Number > 0 -> >>> display_numbers_loop(0, Number ). >>> >>> %% When the control argument)(second argument) is equal to the number >>> %% the user has given, the end is reached and the last number is printed >>> display_numbers_loop(Number, Number) -> >>> ok; >>> >>> %% When the contro argument(second argument) is not equal to the number >>> %% and the Current number is even, >>> %% The control argument is increased by one and the >>> %% display_numbers_loop function is called again with the new arguments. >>> display_numbers_loop(Current, Number) when Current / 2 == 0 -> >>> io:format("Number:~p~n",[Current + 1]), >>> display_numbers_loop(Current +1, Number ); >>> >>> %% When the contro argument(second argument) is not equal to the number >>> %% and the Current number is not even, >>> %% The control argument is increased by one and the >>> %% display_numbers_loop function is called again with the new arguments. >>> display_numbers_loop(Current, Number) when Current / 2 /= 0 -> >>> io:format("Number:~p~n",[Current + 1]), >>> display_numbers_loop(Current +1, Number ). >>> >>> but when I do side_effects(10) I see all the numbers so I wonder why the >>> when is not working ? >>> >>> Roelof >>> >>> _______________________________________________ >>> 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 aschultz@REDACTED Thu Feb 12 18:21:48 2015 From: aschultz@REDACTED (Andreas Schultz) Date: Thu, 12 Feb 2015 17:21:48 +0000 (UTC) Subject: [erlang-questions] IPv6 mutlicast Message-ID: <1808342163.2193625.1423761708976.JavaMail.zimbra@tpip.net> Hi, I'm trying to use IPv6 multicast with 17.4. My current naive attempt is something like this: 1> gen_udp:open(6667, [inet6, binary,{ipv6_v6only, true}, {add_membership, {{16#FF02, 0, 0, 0, 0, 0, 1, 2}, {0,0,0,0,0,0,0,0}}}]). ** exception exit: badarg in function inet6_udp:open/2 (inet6_udp.erl, line 42) I've looked at the source of the badarg failure and after tracing it to prim_inet is_sockopt_val, type_opt and type_value I find this: type_opt_1(add_membership) -> {ip,ip}; type_opt_1(drop_membership) -> {ip,ip}; type_value_2(ip,{A,B,C,D}) when ?ip(A,B,C,D) -> true; It seems that multicast support is only permitted for IPv4 addresses. However, the documentation claims that add_membership takes inet:ip_address() as type, which is defined to mean IPv4 and IPv6 addresses. So, my question is: Is IPv6 multicast supported by 17.4 and how do I use it? Regards Andreas -- -- Dipl. Inform. Andreas Schultz From r.wobben@REDACTED Thu Feb 12 18:55:52 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Thu, 12 Feb 2015 18:55:52 +0100 Subject: [erlang-questions] why does the guard not working In-Reply-To: References: <54DCB9D6.7040006@home.nl> <54DCBAE3.1060405@ericsson.com> <54DCBDD6.9060707@home.nl> Message-ID: <54DCE928.6060500@home.nl> An HTML attachment was scrubbed... URL: From bog495@REDACTED Thu Feb 12 20:44:35 2015 From: bog495@REDACTED (Bogdan Andu) Date: Thu, 12 Feb 2015 21:44:35 +0200 Subject: [erlang-questions] configure http methods in yaws Message-ID: Hi, Can anybody tell how to disable or enable http methods in yaws? For example, I want myu ywas server to serve only GET and POST. and I do not want OPTIONS, HEAD, etc Thanks, Bogdan -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinoski@REDACTED Thu Feb 12 21:01:11 2015 From: vinoski@REDACTED (Steve Vinoski) Date: Thu, 12 Feb 2015 15:01:11 -0500 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: On Thu, Feb 12, 2015 at 2:44 PM, Bogdan Andu wrote: > Hi, > > Can anybody tell how to disable or enable http methods in yaws? > > For example, I want myu ywas server to serve only GET and POST. > and I do not want OPTIONS, HEAD, etc > How are you implementing your resources? Are you using .yaws files, or appmods, or serving static files, or? --steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Thu Feb 12 21:05:12 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 12 Feb 2015 21:05:12 +0100 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: if you use appmods: #arg{} is passed to both appmods' and arg_rewrite_mod's out(Arg) method. #arg{ req:: #http_request{ method } } see yaws_api.hrl for record definitions if the method is not expected, out(Arg) may return {redirect, URL} or {status, StatusCodeInt} or even {'EXIT', normal} (probably best avoided) On 12 February 2015 at 20:44, Bogdan Andu wrote: > Hi, > > Can anybody tell how to disable or enable http methods in yaws? > > For example, I want myu ywas server to serve only GET and POST. > and I do not want OPTIONS, HEAD, etc > > Thanks, > Bogdan > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From bog495@REDACTED Thu Feb 12 21:20:30 2015 From: bog495@REDACTED (Bogdan Andu) Date: Thu, 12 Feb 2015 22:20:30 +0200 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: Hi, I use yapps. The thing is I want to avoid to test at yapp level for allowable methods and return method not allowed at application level Something like inets httpd has ( http://www.erlang.org/doc/apps/inets/http_server.html): Allows only GET and POST order allow deny require group group1 allow from 123.145.244.5 On Thu, Feb 12, 2015 at 10:01 PM, Steve Vinoski wrote: > > > On Thu, Feb 12, 2015 at 2:44 PM, Bogdan Andu wrote: > >> Hi, >> >> Can anybody tell how to disable or enable http methods in yaws? >> >> For example, I want myu ywas server to serve only GET and POST. >> and I do not want OPTIONS, HEAD, etc >> > > How are you implementing your resources? Are you using .yaws files, or > appmods, or serving static files, or? > > --steve > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Thu Feb 12 21:30:46 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 12 Feb 2015 21:30:46 +0100 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: > I want to avoid to test at yapp level for allowable methods config: arg_rewrite_mod = your_module your_module:out(Arg)-> Arg1 = test(Arg) yapp:out(Arg1). ? From vinoski@REDACTED Thu Feb 12 22:54:46 2015 From: vinoski@REDACTED (Steve Vinoski) Date: Thu, 12 Feb 2015 16:54:46 -0500 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: On Thu, Feb 12, 2015 at 3:30 PM, Imants Cekusins wrote: > > I want to avoid to test at yapp level for allowable methods > > config: > arg_rewrite_mod = your_module > > your_module:out(Arg)-> > Arg1 = test(Arg) > yapp:out(Arg1). Right idea, but wrong implementation. A rewriter exports arg_rewrite/1, not out/1, and it doesn't call the target resource directly but lets Yaws do that (if appropriate). Here's an args rewriter that does what's required: -module(methods_rewriter). -export([arg_rewrite/1]). -include_lib("yaws_api.hrl"). arg_rewrite(Arg) -> Allowed = ['GET', 'POST'], Req = yaws_api:arg_req(Arg), Method = yaws_api:http_request_method(Req), case lists:member(Method, Allowed) of true -> Arg; false -> AllowedStrs = string:join([atom_to_list(M) || M <- Allowed], ","), Arg#arg{state= #rewrite_response{ status=405, headers=[{header, {"Allow", AllowedStrs}}, {header, {connection, "close"}}]}} end. If the incoming method is GET or POST, the dispatch continues as normal, otherwise Yaws returns a 405 Method Not Allowed and includes an Allow header indicating only GET and POST are allowed. Compile this and make sure its beam is in the Yaws code load path. In the server config block for your server, set arg_rewrite_mod = methods_rewriter so Yaws knows to use the module for rewriting. Any problems, let me know. --steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Thu Feb 12 23:38:32 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 12 Feb 2015 23:38:32 +0100 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: > A rewriter exports arg_rewrite/1, not out/1, ta, Steve. btw arg_rewrite output spec format: Arg#arg{ state = #rewrite_response{ } } is documented @ https://github.com/klacke/yaws/blob/master/test/t2/rewritetest.erl I should have checked. From vinoski@REDACTED Thu Feb 12 23:51:49 2015 From: vinoski@REDACTED (Steve Vinoski) Date: Thu, 12 Feb 2015 17:51:49 -0500 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: On Thu, Feb 12, 2015 at 5:38 PM, Imants Cekusins wrote: > > A rewriter exports arg_rewrite/1, not out/1, > > ta, Steve. > > btw arg_rewrite output spec format: > > Arg#arg{ > state = #rewrite_response{ } > } > > is documented @ > > https://github.com/klacke/yaws/blob/master/test/t2/rewritetest.erl > > I should have checked. > That's a test for the feature, but you can find documentation here: http://yaws.hyber.org/yaws.pdf BTW I now realize why your example called yapp:out(Arg1): the OP uses yapps, so his arg_rewrite_mod setting will already be set to yapp, so my example needs to take that into account too. It should be the following instead: -module(methods_rewriter). -export([arg_rewrite/1]). -include_lib("yaws_api.hrl"). arg_rewrite(Arg) -> Allowed = ['GET', 'POST'], Req = yaws_api:arg_req(Arg), Method = yaws_api:http_request_method(Req), case lists:member(Method, Allowed) of true -> yapp:arg_rewrite(Arg); false -> AllowedStrs = string:join([atom_to_list(M) || M <- Allowed], ","), Arg#arg{state= #rewrite_response{ status=405, headers=[{header, {"Allow", AllowedStrs}}, {header, {connection, "close"}}]}} end. The difference is that when the method is allowed, we call yapp:arg_rewrite/1 instead of just returning Arg. --steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Fri Feb 13 00:01:28 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 13 Feb 2015 00:01:28 +0100 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: > you can find documentation here:http://yaws.hyber.org/yaws.pdf does not mention #rewrite_response. that's what I mean: goo ( "yaws #rewrite_response" ) output is (or was until now) quite terse ;) From bduggan@REDACTED Fri Feb 13 00:52:25 2015 From: bduggan@REDACTED (Bernard Duggan) Date: Fri, 13 Feb 2015 10:52:25 +1100 Subject: [erlang-questions] New Erlang job openings In-Reply-To: <54D588A3.7050007@bestmx.net> References: <54D3920E.6070901@bestmx.net> <20150207005704.GA1930@corelatus.se> <54D588A3.7050007@bestmx.net> Message-ID: <54DD3CB9.5090801@shoretel.com> On 07/02/15 14:38, e@REDACTED wrote: > On 02/07/2015 01:57 AM, Matthias Lang wrote: >> On 05. February 2015, e@REDACTED wrote: >> >>> Hi, Bruce. >>> please, clarify the issue: >>> why erlangcentral allows non-erlang jobs to be posted? >>> >>> for example the following are C++ and Java positions: >>> >>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >>> >>>> Software Engineer ? New Grad at ShoreTel - Canberra, Australia >>>> https://erlangcentral.org/software-engineer-new-grad-shoretel/ >> >> 1. You've posted the same link twice. >> >> 2. The linked text says "The majority of the development work will >> be in C++ and Erlang." That sounds like an Erlang-related job to me. >> (Or was it ninja-edited?) > > Candidate description > Requirements: > Experience with C++ > Expertise with ... object-oriented programming > Experience with Erlang ... *is a plus* > > "is a plus" sounds like someone else long time ago has coded something > in Erlang > and the candidate will be coding C++ whole day long. I can promise you this is an "Erlang job" (for some reasonable definition thereof) - the mix of code is about 50/50 C/C++ and Erlang, with most new parts being developed in Erlang. I spent yesterday neck-deep in debugging some low-level C, and the day before working on an issue with Erlang. Saying that experience with Erlang is a plus just means we don't expect people to know Erlang before starting, because we need to be realistic about the size of the pool of people for whom that's the case, particularly in a place as small as Canberra. Cheers, Bernard ________________________________ This e-mail and any attachments are confidential. If it is not intended for you, please notify the sender, and please erase and ignore the contents. From imantc@REDACTED Fri Feb 13 01:07:56 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 13 Feb 2015 01:07:56 +0100 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: actually, does Yaws interpret #rewrite_response{} in any way? or is it but a convenience hint to the appmod? if Yaws is looking for #rewrite_response, maybe add a rewrite_response field to #arg so it is obvious where to put it? just an idea.. From vinoski@REDACTED Fri Feb 13 02:39:04 2015 From: vinoski@REDACTED (Steve Vinoski) Date: Thu, 12 Feb 2015 20:39:04 -0500 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: On Thu, Feb 12, 2015 at 7:07 PM, Imants Cekusins wrote: > actually, does Yaws interpret #rewrite_response{} in any way? > or is it but a convenience hint to the appmod? > > if Yaws is looking for #rewrite_response, > maybe add a rewrite_response field to #arg so it is obvious where to put > it? > > just an idea.. > Yes, Yaws knows to check the #arg.state field for a #rewrite_response record and create a response from it if found. As for the new field, that won't happen since it would mean supporting both the state field for existing apps and the new field for new or revised apps. Instead, I'll just add the example from the email thread to the Yaws docs. BTW, here's another way to allow only GET and POST requests, this time using a dispatchmod, which is documented in the PDF docs. A dispatchmod is called very early in the dispatch flow and can either continue dispatching or can send replies directly on the socket and tell Yaws the request is already handled: -module(methods_dpmod). -export([dispatch/1]). -include_lib("yaws_api.hrl"). dispatch(Arg) -> Allowed = ['GET', 'POST'], Req = yaws_api:arg_req(Arg), Method = yaws_api:http_request_method(Req), case lists:member(Method, Allowed) of true -> continue; false -> Vsn = yaws_api:http_request_version(Req), Resp = #http_response{ version=Vsn, status=405, phrase=yaws_api:code_to_phrase(405)}, AllowedStrs = string:join([atom_to_list(M) || M <- Allowed], ","), HdrVals = [{"Allow", AllowedStrs}, {"Content-Length", "0"}], Headers = lists:foldl(fun({H,V}, Hdrs) -> yaws_api:set_header(Hdrs, H, V) end, #headers{}, HdrVals), HdrStrings = yaws_api:reformat_header(Headers), Reply = [yaws_api:reformat_response(Resp), "\r\n", string:join(HdrStrings, "\r\n"), "\r\n\r\n"], Sock = yaws_api:arg_clisock(Arg), case yaws_api:get_sslsocket(Sock) of {ok, SslSock} -> ssl:send(SslSock, Reply); undefined -> gen_tcp:send(Sock, Reply) end, done end. This is a bit more involved than the arg rewriter because it assembles and sends the reply directly. (BTW note that the SSL portions of this example won't work without a very recent version of Yaws, due to a bug I fixed Feb. 3.) --steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Fri Feb 13 03:32:35 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 13 Feb 2015 15:32:35 +1300 Subject: [erlang-questions] is this a well written function In-Reply-To: <54DC503A.60704@home.nl> References: <54D88028.8000802@home.nl> <54DB089D.50900@home.nl> <5E88B594-CE27-44B2-A2C1-B6E57086FEAB@cs.otago.ac.nz> <54DC503A.60704@home.nl> Message-ID: On 12/02/2015, at 8:03 pm, Roelof Wobben wrote: > > Thanks for all the remarks. I changed it all but one remark about your code ; > > When I do N1 = N0 + 1 then I get a error because N1 is imutable and cannot be changed. Here's the code I wrote, pasted from that message. display_numbers_loop(N, N) -> % 3; C ok; % 4; F display_numbers_loop(N0, N) -> % 5; N1 = N0 + 1, % 6; C,D io:format("Number: ~p~n", [N1]), % 7; D display_numbers_loop(N1, N). % 8; At the point that N1 = N0 + 1 happens, N1 DOES NOT YET HAVE A VALUE, so there is no possible question of trying to change it. In fact the code as posted works flawlessly. (I have tested it.) I strongly suspect that you ended up with something like N0 = N0 + 1 ^ which will indeed produce the error you describe. From ok@REDACTED Fri Feb 13 04:30:25 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 13 Feb 2015 16:30:25 +1300 Subject: [erlang-questions] is this a well written function In-Reply-To: <54DC503A.60704@home.nl> References: <54D88028.8000802@home.nl> <54DB089D.50900@home.nl> <5E88B594-CE27-44B2-A2C1-B6E57086FEAB@cs.otago.ac.nz> <54DC503A.60704@home.nl> Message-ID: <356285B5-54A1-4E53-8A00-BBF8434F0DF6@cs.otago.ac.nz> Time to get onto some of the fine detail. (1) The main comment sometimes says "integer" and sometimes says "number". This is at best confusing. All integers are numbers, but not all numbers are integers. (2) "The Erlang Programming book" is not a helpful reference. Which book? Is the book called "Erlang Programming"? Then a better comment would be This is exercise from page of "Programming Erlang" by For example, your b_and/2 &c exercise should have been documented as %%% This module is my solution to exercise 2-3 on page 44 of %%% "Programming Erlang" by Cesarini and Thomson. By the way, that is a really fine book. The wording of some of the exercises could be improved. For example, exercise 3-2 says "format" when it means "form". The first time I saw this book, I was so impressed by the rest of the text that I paid no attention to the exercises. (3) So let's start with a master comment for the module. %%% This module is my solution to exercise 3-3 "Side Effects" on %%% page 83 of "Programming Erlang" by Cesarini and Thomson. (4) Let's note the wording of the exercise. "Write a function that PRINTS out the INTEGERS between 1 and N." "Write a function that PRINTS out the EVEN INTEGERS between 1 and N." It is wise to stick with the words you are given. Someone who knows that you are supposed to "print integers" is going to find 'print_integers' *instantly* understandable, while 'display_numbers' is going to take some decoding: what is the difference between displaying and printing, what is the difference between integers and numbers (is your function meant to handle floats as well?) So we should continue the module like this: -module(exercise_3_2). -export([ print_even_integers/1, print_integers/1 ]). %% "a function that prints out the integers between 1 and N." print_integers(N) when is_integer(N), N >= 0 -> ... %% "a function that prints out the even integers between 1 and N." print_even_integers(N) when is_integer(N), N >= 0 -> ... In the spirit of sticking with the words you are given, the text of the exercise consistently calls the upper bound N. You could make a case for using a *MORE* informative name, such as Upper_Bound. But using Number is not a good idea. It is *different* from the name used in the exercise, so the reader constantly has to keep in mind "Number really means N" instead of the much simpler "N means N", and it does not *help* in any way that N does not. It is in fact *less* helpful than N, because there has been a convention since before Fortran (that since, since before the late 1950s) that N is to be used only for integers. (5) Consistency again. > > display_numbers(Number) when is_integer(Number), Number > 0 -> > display_numbers_loop(0, Number ). You have no space before the right parenthesis in the head, and that is GOOD. You one one space before the right parenthesis in the body, which I find ugly, but some people think it's a good idea. What nobody thinks is a good idea is mixing BOTH styles in the same function! Like everything I've mentioned in this message so far, this has nothing to do with Erlang. Some people consistently write f(X). Some people consistently write f( X ). Some people consistently write f(X ) or consistently write f( X), both of which look horrible to me. Feel free to choose a style without paying any heed to what I like or dislike, but have *reasons* for your choice and be consistent. Cesarini and Thomson's style is consistently - no space after ( in a function call - no space before ) in a function call. > > %% When the control argument)(second argument) (6) This is a classic "incomplete edit" problem. I found one of those in my own code two days ago. I was ashamed of it. A major refactoring had drastically simplified a large file, but some old code that wasn't needed any more was still being called, and in the new context, doing bad things. The control argument is in fact the second. It would be even better to write %% print_integers(N0, N) writes the rest of the integers 1 .. N %% after the integers 1 .. N0 have already been printed. > display_numbers_loop(Current, Number) -> > io:format("Number:~p~n",[Current + 1]), > display_numbers_loop(Current +1, Number ). (7) Consistency again. There are three argument-separating commas. Two of them are followed by spaces but one is not. There are two addition operators. One of them has spaces on both sides, but the other only on one side. Consistency in a layout style doesn't get noticed. Inconsistency in a layout style slows your readers down while they try to figure out whether a difference *means* something or is an accident. By the way, exercise 3-3 includes Hint: use guards. You are using guards to check the argument N, which is fine, but that's not what the hint is pointing you to, and if you had started with print_even_integers/1 first, you would have noticed. Let's be clever. To print all the integers between 1 and N is to print all the integers L, L+1, L+2, ... U where L = 1 and U = N. To print the even integers between 1 and N is to print all the integers L, L+2, L+4, ... U where L = 2 and U = N. If we had a function print_integers(Lower_Bound, Upper_Bound, Increment) that did the obvious thing, then we could write print_integers(1, N) when is_integer(N), N >= 0 -> print_integers(1, N, 1). print_even_integers(1, N) when is_integer(N), N >= 0 -> print_even_integers(2, N, 2). So all we need is print_integers/3. And _that_ is basically display_numbers_loop/2, except that the constant 1 is replaced by the Increment argument, and the test for having printed all the numbers uses a guard Lower_Bound > Upper_Bound instead of a pattern match. Why a guard? Because print_even_integers(5) is going to stop when the next number to print is 6; it will never be 5. (8) AUTHORITIES MAY DISAGREE. In exercise 3-4 on page 84 of Cesarini and Thomson, they tell you to write flatten/1 and hint that you should use concatenate/1 in your answer. It is indeed *possible* to use concatenate/1 in the answer, but it is much simpler and an order of magnitude more efficient not to. I suspect that Cesarini and Thomson are trying to get you to (a) do something with a tree structure, not just a sequence (b) give you some more practice in using building blocks you've just written (c) give you some practice in seeing [_|_] as a binary tree constructor, not specifically a sequence constructor. I can't at the moment see a better exercise they could have written to serve those purposes, but in actual programming practice, using concatenate/1 in flatten/1 is as bad as and for much the same reason as doing string concatenation in a loop in Java. From ok@REDACTED Fri Feb 13 06:20:54 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 13 Feb 2015 18:20:54 +1300 Subject: [erlang-questions] why does the guard not working In-Reply-To: <54DCE928.6060500@home.nl> References: <54DCB9D6.7040006@home.nl> <54DCBAE3.1060405@ericsson.com> <54DCBDD6.9060707@home.nl> <54DCE928.6060500@home.nl> Message-ID: <1D87EE26-690F-438C-A870-CCFF5F3C4D94@cs.otago.ac.nz> You were using display_numbers_loop/1 to print all integers between 1 and N. Now you are using the same name for printing EVEN integers between 1 and N. It would be very helpful to change the name. In order to print even numbers in a range, you are generating ALL integers in that range, and then throwing away the ones you do not want. Fine, in that case display_numbers_loop(N, N) -> ok; display_numbers_loop(N0, N) -> N1 = N0 + 1, case N1 rem 2 of 0 -> io:format("Number: ~p~n", [N1]) ; 1 -> skip end, display_numbers_loop(N1, N). is the smallest change to your display_numbers_loop that will skip the numbers you do not want. But what's better still is not to generate the numbers you don't want in the first place. From r.wobben@REDACTED Fri Feb 13 07:33:24 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Fri, 13 Feb 2015 07:33:24 +0100 Subject: [erlang-questions] why does the guard not working In-Reply-To: <1D87EE26-690F-438C-A870-CCFF5F3C4D94@cs.otago.ac.nz> References: <54DCB9D6.7040006@home.nl> <54DCBAE3.1060405@ericsson.com> <54DCBDD6.9060707@home.nl> <54DCE928.6060500@home.nl> <1D87EE26-690F-438C-A870-CCFF5F3C4D94@cs.otago.ac.nz> Message-ID: <54DD9AB4.2050507@home.nl> Richard A. O'Keefe schreef op 13-2-2015 om 6:20: > You were using display_numbers_loop/1 to print all integers between 1 and N. > Now you are using the same name for printing EVEN integers between 1 and N. > It would be very helpful to change the name. > > In order to print even numbers in a range, you are generating ALL integers > in that range, and then throwing away the ones you do not want. > > Fine, in that case > > display_numbers_loop(N, N) -> > ok; > display_numbers_loop(N0, N) -> > N1 = N0 + 1, > case N1 rem 2 > of 0 -> io:format("Number: ~p~n", [N1]) > ; 1 -> skip > end, > display_numbers_loop(N1, N). > > is the smallest change to your display_numbers_loop that will skip the > numbers you do not want. > > But what's better still is not to generate the numbers you don't want > in the first place. > > Clear explanation. I have to think how I can not generate the numbers I do not want. I think I can use the same idea that you have used to display the even numbers. Roelof From ok@REDACTED Fri Feb 13 07:51:50 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 13 Feb 2015 19:51:50 +1300 Subject: [erlang-questions] why does the guard not working In-Reply-To: <54DD9AB4.2050507@home.nl> References: <54DCB9D6.7040006@home.nl> <54DCBAE3.1060405@ericsson.com> <54DCBDD6.9060707@home.nl> <54DCE928.6060500@home.nl> <1D87EE26-690F-438C-A870-CCFF5F3C4D94@cs.otago.ac.nz> <54DD9AB4.2050507@home.nl> Message-ID: <1196CDE4-E30A-4D84-A94B-040425D03EEE@cs.otago.ac.nz> On 13/02/2015, at 7:33 pm, Roelof Wobben wrote: > Clear explanation. > > I have to think how I can not generate the numbers I do not want. > I think I can use the same idea that you have used to display the even numbers. In C, to print the even integers between 1 and N: for (int I = 2; I <= N; I += 2) { printf("Number: %d\n", I); } Of course, if you know how to iterate over the elements of a list, you could start by making a list of the numbers you want, and then iterate over that. For example, you could write print_even_integers(N) when is_integer(N), N >= 0 -> lists:foreach( fun (X) -> io:format("Number: ~p~n", [X]) end, lists:seq(2, N, 2)). because (recursive) functions "generate an additive sequence of integers" and "do this to every element of that list" have already been written. It has been argued that functional programming is not so much about functions as about writing program pieces you can just plug together. From imantc@REDACTED Fri Feb 13 08:00:06 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 13 Feb 2015 08:00:06 +0100 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: Cheers for another example, Steve! Very useful indeed. > supporting both the state field for existing apps and the new field for new or revised apps well there is probably already a test for #rewrite_response in state field, somewhere. The modified test would be: rewrite_response(Arg1) -> State = Arg1#arg.state, Is_in_state = is_record(State, rewrite_response), case Is_in_state of true -> State; false -> Arg1#arg.rewrite_response end. ? From r.wobben@REDACTED Fri Feb 13 08:01:08 2015 From: r.wobben@REDACTED (Roelof Wobben) Date: Fri, 13 Feb 2015 08:01:08 +0100 Subject: [erlang-questions] why does the guard not working In-Reply-To: <1196CDE4-E30A-4D84-A94B-040425D03EEE@cs.otago.ac.nz> References: <54DCB9D6.7040006@home.nl> <54DCBAE3.1060405@ericsson.com> <54DCBDD6.9060707@home.nl> <54DCE928.6060500@home.nl> <1D87EE26-690F-438C-A870-CCFF5F3C4D94@cs.otago.ac.nz> <54DD9AB4.2050507@home.nl> <1196CDE4-E30A-4D84-A94B-040425D03EEE@cs.otago.ac.nz> Message-ID: <54DDA134.8040009@home.nl> Richard A. O'Keefe schreef op 13-2-2015 om 7:51: > On 13/02/2015, at 7:33 pm, Roelof Wobben wrote: >> Clear explanation. >> >> I have to think how I can not generate the numbers I do not want. >> I think I can use the same idea that you have used to display the even numbers. > In C, to print the even integers between 1 and N: > > for (int I = 2; I <= N; I += 2) { > printf("Number: %d\n", I); > } > > Of course, if you know how to iterate over the elements of a list, > you could start by making a list of the numbers you want, and > then iterate over that. For example, you could write > > print_even_integers(N) when is_integer(N), N >= 0 -> > lists:foreach( > fun (X) -> io:format("Number: ~p~n", [X]) end, > lists:seq(2, N, 2)). > > because (recursive) functions "generate an additive sequence of > integers" and "do this to every element of that list" have already > been written. It has been argued that functional programming is > not so much about functions as about writing program pieces you > can just plug together. > > Thanks, The problem is here you use the lists functions and I think Im now allowed to use them. Roelof From bog495@REDACTED Fri Feb 13 08:33:08 2015 From: bog495@REDACTED (Bogdan Andu) Date: Fri, 13 Feb 2015 09:33:08 +0200 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: The idea of configuration module is a step forward, but I just want to tell yaws to handle only the methods I want , automagically. I do not want another module to interfere with http traffic. Traffic with methods not allowed should be discarded with 405 in the earliest stage of proccessing. On Fri, Feb 13, 2015 at 3:39 AM, Steve Vinoski wrote: > > On Thu, Feb 12, 2015 at 7:07 PM, Imants Cekusins wrote: > >> actually, does Yaws interpret #rewrite_response{} in any way? >> or is it but a convenience hint to the appmod? >> >> if Yaws is looking for #rewrite_response, >> maybe add a rewrite_response field to #arg so it is obvious where to put >> it? >> >> just an idea.. >> > > Yes, Yaws knows to check the #arg.state field for a #rewrite_response > record and create a response from it if found. As for the new field, that > won't happen since it would mean supporting both the state field for > existing apps and the new field for new or revised apps. Instead, I'll just > add the example from the email thread to the Yaws docs. > > BTW, here's another way to allow only GET and POST requests, this time > using a dispatchmod, which is documented in the PDF docs. A dispatchmod is > called very early in the dispatch flow and can either continue dispatching > or can send replies directly on the socket and tell Yaws the request is > already handled: > > -module(methods_dpmod). > -export([dispatch/1]). > > -include_lib("yaws_api.hrl"). > > dispatch(Arg) -> > Allowed = ['GET', 'POST'], > Req = yaws_api:arg_req(Arg), > Method = yaws_api:http_request_method(Req), > case lists:member(Method, Allowed) of > true -> > continue; > false -> > Vsn = yaws_api:http_request_version(Req), > Resp = #http_response{ > version=Vsn, > status=405, > phrase=yaws_api:code_to_phrase(405)}, > AllowedStrs = string:join([atom_to_list(M) || M <- Allowed], > ","), > HdrVals = [{"Allow", AllowedStrs}, > {"Content-Length", "0"}], > Headers = lists:foldl(fun({H,V}, Hdrs) -> > yaws_api:set_header(Hdrs, H, V) > end, #headers{}, HdrVals), > HdrStrings = yaws_api:reformat_header(Headers), > Reply = [yaws_api:reformat_response(Resp), "\r\n", > string:join(HdrStrings, "\r\n"), "\r\n\r\n"], > Sock = yaws_api:arg_clisock(Arg), > case yaws_api:get_sslsocket(Sock) of > {ok, SslSock} -> > ssl:send(SslSock, Reply); > undefined -> > gen_tcp:send(Sock, Reply) > end, > done > end. > > This is a bit more involved than the arg rewriter because it assembles and > sends the reply directly. (BTW note that the SSL portions of this example > won't work without a very recent version of Yaws, due to a bug I fixed Feb. > 3.) > > --steve > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Fri Feb 13 09:17:16 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 13 Feb 2015 09:17:16 +0100 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: > Traffic with methods not allowed should be discarded with 405 you see, someone else might prefer another action depending on method not allowed. a dedicated attribute may be convenient but then someone would ask: "how do I change the response code? how do I redirect?". Current approach gives you choice. one of those cases when there is more than one approach, a prefers A, b prefers B. Both have a valid point. From bog495@REDACTED Fri Feb 13 10:30:28 2015 From: bog495@REDACTED (Bogdan Andu) Date: Fri, 13 Feb 2015 11:30:28 +0200 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: Yes but the point is to have a default configuration that can be overridden by such a mechanism if one is configured. The 99 percent of cases only need a default behaviour. The way I see this is to have something like that (all in one): mod_405=my_405_handle_module .... in this way we can also customize the response if a method other than GET or POST is sent to the server On Fri, Feb 13, 2015 at 10:17 AM, Imants Cekusins wrote: > > Traffic with methods not allowed should be discarded with 405 > > you see, someone else might prefer another action depending on method > not allowed. > > a dedicated attribute may be convenient but then someone would ask: > "how do I change the response code? how do I redirect?". Current > approach gives you choice. > > one of those cases when there is more than one approach, a prefers A, > b prefers B. Both have a valid point. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Fri Feb 13 17:03:02 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Fri, 13 Feb 2015 17:03:02 +0100 Subject: [erlang-questions] TCP open port count Message-ID: Dear list, Is there a system command that can easily tell me how many TCP ports are open on a system? erlang:system_info(port_count) This returns all port, I'd like to know only the TCP ones. Thank you, r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vinoski@REDACTED Fri Feb 13 17:14:44 2015 From: vinoski@REDACTED (Steve Vinoski) Date: Fri, 13 Feb 2015 11:14:44 -0500 Subject: [erlang-questions] configure http methods in yaws In-Reply-To: References: Message-ID: I don't recall seeing Yaws users asking for this config feature in the past, so it's unlikely we'll add it. But what you're asking for -- a configuration point for methods -- would be implemented much as I've shown in my previous emails, much like a dispatchmod. The dispatchmod is as early in the request handling process as you can get after the formation of the #arg{}. The dispatchmod code I provided requires less configuration than what you're showing, even for the default case, plus if having to have a new module concerns you, the dispatch/1 function can be added to some other existing module you already have instead. --steve On Fri, Feb 13, 2015 at 4:30 AM, Bogdan Andu wrote: > Yes but the point is to have a default configuration that can be > overridden by such a mechanism > if one is configured. > The 99 percent of cases only need a default behaviour. > > The way I see this is to have something like that (all in one): > > > mod_405=my_405_handle_module > .... > > > in this way we can also customize the response if a method other than GET > or POST is sent to the server > > On Fri, Feb 13, 2015 at 10:17 AM, Imants Cekusins > wrote: > >> > Traffic with methods not allowed should be discarded with 405 >> >> you see, someone else might prefer another action depending on method >> not allowed. >> >> a dedicated attribute may be convenient but then someone would ask: >> "how do I change the response code? how do I redirect?". Current >> approach gives you choice. >> >> one of those cases when there is more than one approach, a prefers A, >> b prefers B. Both have a valid point. >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From z@REDACTED Fri Feb 13 17:17:47 2015 From: z@REDACTED (Danil Zagoskin) Date: Fri, 13 Feb 2015 20:17:47 +0400 Subject: [erlang-questions] TCP open port count In-Reply-To: References: Message-ID: A slow but working way could be iterating over all ports searching for tcp ones: length([P || P <- erlang:ports(), erlang:port_info(P, name) == {name,"tcp_inet"}]). And this is what inet:i(tcp) actually does. On Fri, Feb 13, 2015 at 7:03 PM, Roberto Ostinelli wrote: > Dear list, > Is there a system command that can easily tell me how many TCP ports are > open on a system? > > erlang:system_info(port_count) > > This returns all port, I'd like to know only the TCP ones. > > Thank you, > r. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -- Danil Zagoskin | z@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Fri Feb 13 17:26:57 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Fri, 13 Feb 2015 17:26:57 +0100 Subject: [erlang-questions] Mnesia create tables best practices In-Reply-To: References: <87467EDF-C075-4F77-8993-C4108D2432A6@widetag.com> <7A8865DD-DD04-4637-B965-85CD9014873E@widetag.com> Message-ID: Thank you Jesper. Best, r. On Wed, Feb 11, 2015 at 3:01 PM, Jesper Louis Andersen < jesper.louis.andersen@REDACTED> wrote: > > On Wed, Feb 11, 2015 at 9:07 AM, Roberto Ostinelli < > roberto.ostinelli@REDACTED> wrote: > >> Adding to this: doesn't it mean that the name and full host of the node >> need to be known before you can initialize your db, hence a release can >> only be specific for a specific full node name? > > > Indeed, distributed mnesia requires a node list when creating the schema. > So this makes the database specific to the installation. This is not unique > in any way, as RDBMS systems in general has this requirement of "pool > initialization", where initial schemas, clustering and replication > configuration has to happen. In this case, schema creation needs a separate > target, and it is often beneficial to store the mnesia dir outside the > release for easier upgrades. > > What I'm coming at is that mnesia was not created for idempotent database > initialization. Other systems may be far better at this, where one can join > new nodes to an existing system dynamically. The task is even automatic in > some systems. But for mnesia, you need to write code. Code gives control > and flexibility at the expense of simple deployment. On the other hand, you > wont be surprised by system behaviour since you wrote the code yourself. > Here is one way to go about it. > > Initialize a ``root'' which stores the schema and uses a predefined schema > upon boot. Every other node now joins the cluster, with an empty schema. > You start mnesia on a new node. You call > `mnesia:change_config(extra_db_nodes, ['joiner@REDACTED'])` on root > followed by `mnesia:change_table_copy(schema, 'joiner@REDACTED', > disc_copies)` so the schema is on the disc of the newly joined node. > > From here, you can run `mnesia:add_table_copy(Table, 'joiner@REDACTED', > Type)` to copy tables to the newly joined node for the tables which needs > to be added. > > In turn, you have two release configurations. One in which the node boots > with a predefined schema, and one where it boots in a ram_copies schema > mode and doesn't start operating before it has been joined to a cluster. > Once it has been joined, it has a valid mnesia database and is ready for > doing work in the cluster. > > If you want the ability to truly elastically add and remove nodes from a > cluster, you probably shouldn't use mnesia. The reason has to do with > mnesia's inability to automatically work with network splits and split > brain. You can add nodes to mnesia ``up to a point'', after which you will > have to move to another database system. As I've argued before[0], in the > sense of the CAP theorem, mnesia is neither CP, nor AP and ``CA'' doesn't > exist as a mode. Remember that mnesia predates the CAP theorem by a couple > of years, and partitioning is highly unlikely in a system where > communication is on the same cross-backplane as your telephony switching > calls. For AP systems, Riak is perhaps the weapon of choice for Erlang > programmers. For a CP system, I don't really have a good elastic candidate, > but others may. > > Where mnesia shines are: > > * The cluster is of moderate size, perhaps less than 16 nodes. > * The FULL database can be in memory, or if using fragmented tables, loss > of a fragment is not equal to total system catastrophe. > * Interaction between the Erlang processes and the data is tight, so > having access to QLC is important. > * You have most queries as K/V lookups requiring microsecond latency with > few complicated queries joining many tables. In the latter case, you care > about correctness, not latency. > * The most likely failure is loss of a node. It happens rarely and it is > possible to solve through manual intervention in a window of a couple of > days/weeks. > > > [0] https://medium.com/@jlouis666/mnesia-and-cap-d2673a92850 > > > -- > J. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From icfp.publicity@REDACTED Fri Feb 13 17:26:30 2015 From: icfp.publicity@REDACTED (David Van Horn) Date: Fri, 13 Feb 2015 11:26:30 -0500 Subject: [erlang-questions] ICFP 2015: Final Call for Papers Message-ID: ===================================================================== 20th ACM SIGPLAN International Conference on Functional Programming ICFP 2015 Vancouver, Canada, August 31 - September 2, 2015 http://www.icfpconference.org/icfp2015 ===================================================================== Important Dates ~~~~~~~~~~~~~~~ Submissions due: Friday, February 27 2015, 23:59 UTC-11 https://icfp15.hotcrp.com/ Author response: Tuesday, April 21, 2015 through Thursday, 23 April, 2015 Notification: Friday, May 1, 2015 Final copy due: Friday, June 12, 2015 Scope ~~~~~ ICFP 2015 seeks original papers on the art and science of functional programming. Submissions are invited on all topics from principles to practice, from foundations to features, and from abstraction to application. The scope includes all languages that encourage functional programming, including both purely applicative and imperative languages, as well as languages with objects, concurrency, or parallelism. Topics of interest include (but are not limited to): * Language Design: concurrency, parallelism, and distribution; modules; components and composition; metaprogramming; type systems; interoperability; domain-specific languages; and relations to imperative, object-oriented, or logic programming. * Implementation: abstract machines; virtual machines; interpretation; compilation; compile-time and run-time optimization; garbage collection and memory management; multi-threading; exploiting parallel hardware; interfaces to foreign functions, services, components, or low-level machine resources. * Software-Development Techniques: algorithms and data structures; design patterns; specification; verification; validation; proof assistants; debugging; testing; tracing; profiling. * Foundations: formal semantics; lambda calculus; rewriting; type theory; monads; continuations; control; state; effects; program verification; dependent types. * Analysis and Transformation: control-flow; data-flow; abstract interpretation; partial evaluation; program calculation. * Applications: symbolic computing; formal-methods tools; artificial intelligence; systems programming; distributed-systems and web programming; hardware design; databases; XML processing; scientific and numerical computing; graphical user interfaces; multimedia and 3D graphics programming; scripting; system administration; security. * Education: teaching introductory programming; parallel programming; mathematical proof; algebra. * Functional Pearls: elegant, instructive, and fun essays on functional programming. * Experience Reports: short papers that provide evidence that functional programming really works or describe obstacles that have kept it from working. If you are concerned about the appropriateness of some topic, do not hesitate to contact the program chair. Abbreviated instructions for authors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * By Friday, 27 February 2015, 23:59 UTC-11, submit a full paper of at most 12 pages (6 pages for an Experience Report) in standard ACM conference format, including bibliography, figures, and appendices. The deadlines will be strictly enforced and papers exceeding the page limits will be summarily rejected. * Authors have the option to attach supplementary material to a submission, on the understanding that reviewers may choose not to look at it. * Each submission must adhere to SIGPLAN's republication policy, as explained on the web at http://www.sigplan.org/Resources/Policies/Republication * Authors of resubmitted (but previously rejected) papers have the option to attach an annotated copy of the reviews of their previous submission(s), explaining how they have addressed these previous reviews in the present submission. If a reviewer identifies him/herself as a reviewer of this previous submission and wishes to see how his/her comments have been addressed, the program chair will communicate to this reviewer the annotated copy of his/her previous review. Otherwise, no reviewer will read the annotated copies of the previous reviews. Overall, a submission will be evaluated according to its relevance, correctness, significance, originality, and clarity. It should explain its contributions in both general and technical terms, clearly identifying what has been accomplished, explaining why it is significant, and comparing it with previous work. The technical content should be accessible to a broad audience. Functional Pearls and Experience Reports are separate categories of papers that need not report original research results and must be marked as such at the time of submission. Detailed guidelines on both categories are on the conference web site. Proceedings will be published by ACM Press. Authors of accepted submissions will have a choice of one of three ways to manage their publication rights. These choices are described at http://authors.acm.org/main.html Presentations will be videotaped and released online if the presenter consents. The proceedings will be freely available for download from the ACM Digital Library from one week before the start of the conference until two weeks after the conference. Formatting: Submissions must be in PDF format printable in black and white on US Letter sized paper and interpretable by Ghostscript. Papers must adhere to the standard ACM conference format: two columns, nine-point font on a ten-point baseline, with columns 20pc (3.33in) wide and 54pc (9in) tall, with a column gutter of 2pc (0.33in). A suitable document template for LaTeX is available at http://www.sigplan.org/Resources/Author/ Submission: Submissions will be accepted on the web using a link that will be posted at https://icfp15.hotcrp.com/ Improved versions of a paper may be submitted at any point before the submission deadline using the same web interface. Author response: Authors will have a 72-hour period, starting at 0:00 UTC on Tuesday, 21 April 2015, to read reviews and respond to them. ACM Author-Izer is a unique service that enables ACM authors to generate and post links on either their home page or institutional repository for visitors to download the definitive version of their articles from the ACM Digital Library at no charge. Downloads through Author-Izer links are captured in official ACM statistics, improving the accuracy of usage and impact measurements. Consistently linking the definitive version of ACM article should reduce user confusion over article versioning. After your article has been published and assigned to your ACM Author Profile page, please visit http://www.acm.org/publications/acm-author-izer-service to learn how to create your links for free downloads from the ACM DL. Publication date: The official publication date of accepted papers is the date the proceedings are made available in the ACM Digital Library. This date may be up to two weeks prior to the first day of the conference. The official publication date affects the deadline for any patent filings related to published work. General Chair: Kathleen Fisher Tufts University (USA) Program Chair: John Reppy University of Chicago (USA) Program Committee: Amal Ahmed Northeastern University (USA) Jean-Philippe Bernardy Chalmers University of Technology (Sweden) Matthias Blume Google (USA) William Byrd University of Utah (USA) Andy Gill University of Kansas (USA) Neal Glew Google (USA) Fritz Henglein University of Copenhagen (Denmark) Gabriele Keller University of New South Wales and NICTA (Australia) Andrew Kennedy Microsoft Research Cambridge (UK) Neelakantan Krishnaswami Birmingham University (UK) Daan Leijen Microsoft Research Redmond (USA) Keiko Nakata FireEye Dresden (Germany) Mike Rainey INRIA Rocquencourt (France) Andreas Rossberg Google (Germany) Manuel Serrano INRIA Sophia Antipolis (France) Simon Thompson University of Kent (UK) David Van Horn University of Maryland (USA) Stephanie Weirich University of Pennsylvania (USA) From comptekki@REDACTED Fri Feb 13 17:59:30 2015 From: comptekki@REDACTED (Wes James) Date: Fri, 13 Feb 2015 09:59:30 -0700 Subject: [erlang-questions] TCP open port count In-Reply-To: References: Message-ID: Via os:cmd?? {Open_ports_pre, _} = string:to_integer(os:cmd("netstat -a | egrep 'Proto|LISTEN' | wc -l")). Open_ports = Open_ports_pre-2. -wes On Fri, Feb 13, 2015 at 9:03 AM, Roberto Ostinelli wrote: > Dear list, > Is there a system command that can easily tell me how many TCP ports are > open on a system? > > erlang:system_info(port_count) > > This returns all port, I'd like to know only the TCP ones. > > Thank you, > r. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto.ostinelli@REDACTED Sat Feb 14 13:25:06 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Sat, 14 Feb 2015 13:25:06 +0100 Subject: [erlang-questions] TCP open port count In-Reply-To: References: Message-ID: <43F6445F-E76D-4AA8-8AB0-91F71047DB75@widetag.com> Indeed. However, since this information is available in crash dumps (i.e. howmany tcp and udp ports were used) I thought there might be a direct way to access this information. Maybe when a crash dump is generated, there is a loop that checks for every port type just in the way that it has been suggested. > On 13/feb/2015, at 17:59, Wes James wrote: > > Via os:cmd?? > > {Open_ports_pre, _} = string:to_integer(os:cmd("netstat -a | egrep 'Proto|LISTEN' | wc -l")). > > Open_ports = Open_ports_pre-2. > > -wes > >> On Fri, Feb 13, 2015 at 9:03 AM, Roberto Ostinelli wrote: >> Dear list, >> Is there a system command that can easily tell me how many TCP ports are open on a system? >> >> erlang:system_info(port_count) >> >> This returns all port, I'd like to know only the TCP ones. >> >> Thank you, >> r. >> >> _______________________________________________ >> 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 roberto.ostinelli@REDACTED Sat Feb 14 16:25:22 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Sat, 14 Feb 2015 16:25:22 +0100 Subject: [erlang-questions] TCP open port count In-Reply-To: References: Message-ID: <196E8301-6984-42B2-BC13-3F7EC2056E27@widetag.com> Thank you Danil, will use this. Best, r. > On 13/feb/2015, at 17:17, Danil Zagoskin wrote: > > A slow but working way could be iterating over all ports searching for tcp ones: > length([P || P <- erlang:ports(), erlang:port_info(P, name) == {name,"tcp_inet"}]). > > And this is what inet:i(tcp) actually does. > >> On Fri, Feb 13, 2015 at 7:03 PM, Roberto Ostinelli wrote: >> Dear list, >> Is there a system command that can easily tell me how many TCP ports are open on a system? >> >> erlang:system_info(port_count) >> >> This returns all port, I'd like to know only the TCP ones. >> >> Thank you, >> r. >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > > > > -- > Danil Zagoskin | z@REDACTED -------------- next part -------------- An HTML attachment was scrubbed... URL: From zengjiestc@REDACTED Sat Feb 14 19:35:50 2015 From: zengjiestc@REDACTED (=?UTF-8?B?5pu+5p2w?=) Date: Sun, 15 Feb 2015 02:35:50 +0800 Subject: [erlang-questions] new user want to encode & decode h248 protocol Message-ID: Hi I'm new user of erlang, I want to encode & decode h248 packets captured from network. I want to use open source h248 protocol stack to complete this work. Use google, I found erlang/otp can do this, but my program experience is c++, so I have to learn erlang for this problem. In erlang's megaco document, the example is about how to implement mg/mgc, but I need not to implement mg/mgc, I only need encode & decode h248 protocol, and recover the calling procedure in human readable format. My problem is: how to use erlang's lib to encode & decode h248 packets captured from network ( use tcpdump), and recover the calling procedure? Please give me some hints about this ( as simple as possible, because I have learned erlang only one day ). Thank you very much! -------------- next part -------------- An HTML attachment was scrubbed... URL: From donpedrothird@REDACTED Sun Feb 15 20:03:59 2015 From: donpedrothird@REDACTED (John Doe) Date: Sun, 15 Feb 2015 23:03:59 +0400 Subject: [erlang-questions] Formatting strings with named arguments Message-ID: Hi, Are there any libraries to format strings with named arguments, like in python "%(name)s" % {"name": "somename"}? -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Sun Feb 15 20:15:23 2015 From: imantc@REDACTED (Imants Cekusins) Date: Sun, 15 Feb 2015 20:15:23 +0100 Subject: [erlang-questions] Formatting strings with named arguments In-Reply-To: References: Message-ID: re:replace does it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From donpedrothird@REDACTED Sun Feb 15 20:21:09 2015 From: donpedrothird@REDACTED (John Doe) Date: Sun, 15 Feb 2015 23:21:09 +0400 Subject: [erlang-questions] Formatting strings with named arguments In-Reply-To: References: Message-ID: re:replace can't do padding, conversion to strings and other things expected from format function. Also it can't do multiple replacement of different named parameters in one run 2015-02-15 22:15 GMT+03:00 Imants Cekusins : > re:replace > does it. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Sun Feb 15 20:44:23 2015 From: imantc@REDACTED (Imants Cekusins) Date: Sun, 15 Feb 2015 20:44:23 +0100 Subject: [erlang-questions] Formatting strings with named arguments In-Reply-To: References: Message-ID: io_lib:format substitutes multiple placeholders, converts to string, does padding. You could 1) search for named placeholders using re:run 2) replace placeholders with ~s or ~p using re:replace 3) prepare a list with substitutes from a map|dict 4) pass this list to io_lib:format. A bit of work but doable. -------------- next part -------------- An HTML attachment was scrubbed... URL: From donpedrothird@REDACTED Sun Feb 15 20:54:30 2015 From: donpedrothird@REDACTED (John Doe) Date: Sun, 15 Feb 2015 23:54:30 +0400 Subject: [erlang-questions] Formatting strings with named arguments In-Reply-To: References: Message-ID: yeah, already wrote something like this format(String, Parameters) -> Parts = re:split(String, "~(.*?)\\((.*?)\\)(.)", [{return, binary}, group, trim]), Replace = fun ([Bin]) -> Bin; ([Prefix, Modifier, Name, F]) -> case lists:keyfind(Name, 1, Parameters) of false -> exit([<<"String format: parameter ">>, Name, <<" not found.">>]); {_, Val} -> [Prefix, io_lib:format(<<"~", Modifier/binary, F/binary>>, [Val])] end end, [Replace(Part) || Part <- Parts]. >iolist_to_binary(format("start~(foo)Bmiddle~10(bar)send", [{<<"foo">>, 123}, {<<"bar">>, <<"qwerty">>}])). <<"start123middle qwertyend">> 2015-02-15 22:44 GMT+03:00 Imants Cekusins : > io_lib:format > substitutes multiple placeholders, converts to string, does padding. > > You could > 1) search for named placeholders using re:run > > 2) replace placeholders with ~s or ~p using re:replace > > 3) prepare a list with substitutes from a map|dict > > 4) pass this list to io_lib:format. > > A bit of work but doable. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob@REDACTED Sun Feb 15 21:05:34 2015 From: bob@REDACTED (Bob Ippolito) Date: Sun, 15 Feb 2015 12:05:34 -0800 Subject: [erlang-questions] Formatting strings with named arguments In-Reply-To: References: Message-ID: Yes, there's one in mochiweb. https://github.com/mochi/mochiweb/blob/master/src/mochifmt.erl On Sun, Feb 15, 2015 at 11:03 AM, John Doe wrote: > Hi, > Are there any libraries to format strings with named arguments, like in > python "%(name)s" % {"name": "somename"}? > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon Feb 16 00:21:08 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 16 Feb 2015 12:21:08 +1300 Subject: [erlang-questions] why does the guard not working In-Reply-To: <54DDA134.8040009@home.nl> References: <54DCB9D6.7040006@home.nl> <54DCBAE3.1060405@ericsson.com> <54DCBDD6.9060707@home.nl> <54DCE928.6060500@home.nl> <1D87EE26-690F-438C-A870-CCFF5F3C4D94@cs.otago.ac.nz> <54DD9AB4.2050507@home.nl> <1196CDE4-E30A-4D84-A94B-040425D03EEE@cs.otago.ac.nz> <54DDA134.8040009@home.nl> Message-ID: I wrote: >> Of course, if you know how to iterate over the elements of a list, >> you could start by making a list of the numbers you want, and >> then iterate over that. For example, you could write >> >> print_even_integers(N) when is_integer(N), N >= 0 -> >> lists:foreach( >> fun (X) -> io:format("Number: ~p~n", [X]) end, >> lists:seq(2, N, 2)). >> >> because (recursive) functions "generate an additive sequence of >> integers" and "do this to every element of that list" have already >> been written. It has been argued that functional programming is >> not so much about functions as about writing program pieces you >> can just plug together. On 13/02/2015, at 8:01 pm, Roelof Wobben wrote: > The problem is here you use the lists functions and I think Im now allowed to use them. There's a little misunderstanding here. I was not saying "here is a better way to solve this exercise AS an exercise". I was providing a lesson: "the way you solve the exercise AS an exercise is NOT the way you would solve it if you had it as a REAL WORLD problem." In Haskell, I might write n = ... main = putStr $ unlines $ map show $ [2,4..n] -- [2,4..n] make the list of even integers -- map show $ .. convert every element to a string -- unlines $ paste the strings together with a newline at the end of each -- putStr $ .. print the string where I would have written no loop or recursive function myself. Yes, to use functional programming languages effectively you do have to master recursion (which is really no harder than iteration). But eventually, you should be writing fewer and fewer such functions while *using* more and more. Now that more and more programming languages (Python, Java, C#, Javascript, ..., even C has anonymous functions in Mac OS X) are catching up with where functional programming was in the 1960s, this kind of abstraction is becoming possible quite generally, so this way of thinking is becoming useful even in quite surprising languages. From petergi@REDACTED Mon Feb 16 06:06:45 2015 From: petergi@REDACTED (Peter J Etheridge) Date: Mon, 16 Feb 2015 16:06:45 +1100 Subject: [erlang-questions] your first choice? Message-ID: dear erlangers, with my plan to build a web app (a yapp was what i had in mind) i have been studying tools. there seems to be general agreement on rebar.?but which should i choose;yaws or mochiweb?mnesia or mongoDB?chicago boss or ...?XML or JSon?intellij idea or eclipse?and before i buy a server, Win or Linux or ...??while whatever i study seems ok, it is all taking a lot of time and keeping me from coding in erlang.there is some good info on the web, but i value your opinions more.understanding you will be required to maintain your app, if you were starting from scratch, which choice would you make first?appreciative thanks,peter -------------- next part -------------- An HTML attachment was scrubbed... URL: From zxq9@REDACTED Mon Feb 16 06:45:55 2015 From: zxq9@REDACTED (zxq9) Date: Mon, 16 Feb 2015 14:45:55 +0900 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: <3875190.04S1WXKUJV@changa> On 2015?2?16? ??? 16:06:45 Peter J Etheridge wrote: > dear erlangers, > with my plan to build a web app (a yapp was what i had in mind) i have > been studying tools. > there seems to be general agreement on rebar. but which should i > choose;yaws or mochiweb?mnesia or mongoDB?chicago boss or ...?XML or > JSon?intellij idea or eclipse?and before i buy a server, Win or Linux > or ...? while whatever i study seems ok, it is all taking a lot of > time and keeping me from coding in erlang.there is some good info on > the web, but i value your opinions more.understanding you will be > required to maintain your app, if you were starting from scratch, > which choice would you make first?appreciative thanks,peter YAWS on some open source Unixy OS. The OS will be free to mess with, containerize, migrate among hosts, be familiar to anyone you might want to work together with, etc. YAWS requires only knowing one language on the server-side, one environment that constitutes the entire web "stack" (written in the same language you'll use for server- side app development), and is the shortest route to the "hello, world" stage from which your application development can be incremental tweaks. As you learn more under YAWS you may decide for whatever reason that some other server system is better suited to your style of thought or to your problem, and if you develop your server-side stuff in a way that doesn't entangle it with YAWS directly then moving isn't that hard anyway. In any case, you're unlikely to get a non-trivial application built right the first time. If YAWS turns out to suck for some reason, at least you'll know what points of pain you're looking to alleviate on the next try and won't have spent an inordinate amount of time messing with application interaction mysteries since YAWS is pretty much a self-contained system written with just one purpose in mind. In my opinion "web stacks" that are anything larger than two layers deep (as in [Server, YourStuff]) are generally a bad idea because one often to winds up spending more time dicking with the medium than the message. Unfortunately JS is going to continue to be a joke and is the only real option client-side, but its better than nothing and websockets have alleviated a major point of ridiculousness that existed for over a decade. My 2c. -Craig From imantc@REDACTED Mon Feb 16 11:11:06 2015 From: imantc@REDACTED (Imants Cekusins) Date: Mon, 16 Feb 2015 11:11:06 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <3875190.04S1WXKUJV@changa> References: <3875190.04S1WXKUJV@changa> Message-ID: > XML or JSon? Json. It is more compact and useful in browser. > intellij idea or eclipse? Intellij Idea is very good IDE. It works with a variety of programming languages within a single project. Did not use Eclipse so can't vouch for it. > and before i buy a server, Win or Linux or ...? both Win and Linux (at least some OS) support Virtual machines so you can run Win on Linux or Linux on Win if you change your mind later. Win is easier to configure. Most Linux-targeted programs are better suited for, or work only with Linux. In capable hands Linux consumes less resources and can handle higher load. From davidnwelton@REDACTED Mon Feb 16 12:31:12 2015 From: davidnwelton@REDACTED (David Welton) Date: Mon, 16 Feb 2015 12:31:12 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: Hi, > dear erlangers, > with my plan to build a web app (a yapp was what i had in mind) i have been > studying tools. > there seems to be general agreement on rebar. > but which should i choose; This is "asking for it", as they say, as there's nothing that gets programmers going more than a good discussion of tools :-) > yaws or mochiweb? > mnesia or mongoDB? > chicago boss or ...? > XML or JSon? > intellij idea or eclipse? > and before i buy a server, Win or Linux or ...? > while whatever i study seems ok, it is all taking a lot of time and keeping > me from coding in erlang. > there is some good info on the web, but i value your opinions more. > understanding you will be required to maintain your app, if you were > starting from scratch, which choice would you make first? I'd turn the problem around. What are you trying to do, and why are you set on using Erlang for it? "Learning Erlang" is a perfectly acceptable response, but it does color the discussion some. I've been doing "web stuff" for nearly 20 years, and here's my opinion about the state of Erlang and "web stuff": * It's got most of the pieces you need. * There is no really good framework that puts them all together in a decent way to get started. Chicago Boss was a valiant attempt at this, but... it's got some warts. * As an example of the kind of thing you'll have to learn about and put together yourself, consider using a database: at a minimum, you're going to want to integrate something like fuse and poolboy to make it work at any kind of scale, and make it work robustly. * The bits and pieces I would use: cowboy web server, Postgres database with epgsql, erlydtl for templates, jiffy for json, poolboy, fuse, lager, recon, relx and a few other bits and pieces. * If putting all that together is not your thing, and you are more interested in getting something up and running as soon as possible, you might look at other languages. Elixir's Phoenix framework runs on the same VM as Erlang. Going further afield, you have all kinds of choices, which have their own advantages and disadvantages, depending on what you want to accomplish. I'm personally a fan of Ruby on Rails for how much stuff you can do by including various libraries. People have managed to build businesses on PHP, Node.js, Java, Python, Perl, Tcl and all kinds of other systems. * Don't buy a computer, rent a VPS via something like Linode, and run Linux (or maybe some BSD system if you feel adventurous). -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From radek@REDACTED Mon Feb 16 13:16:55 2015 From: radek@REDACTED (Radoslaw Gruchalski) Date: Mon, 16 Feb 2015 13:16:55 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: I've done a little bit of web stuff in Erlang recently as part of learning Erlang and the components mentioned by David is (mostly) what I used. This is a great answer. I think the only thing I would love to add is that Apache Thrift JSON protocol seems to be the most approachable way of transforming to and from JSON in Erlang. I'd definitely play with that. Kind regards, Radek Gruchalski radek@REDACTED *Confidentiality:* This communication is intended for the above-named person and may be confidential and/or legally privileged. If it has come to you in error you must take no action based on it, nor must you copy or show it to anyone; please delete/destroy and inform the sender immediately. On Mon, Feb 16, 2015 at 12:31 PM, David Welton wrote: > Hi, > > > dear erlangers, > > with my plan to build a web app (a yapp was what i had in mind) i have > been > > studying tools. > > there seems to be general agreement on rebar. > > but which should i choose; > > This is "asking for it", as they say, as there's nothing that gets > programmers going more than a good discussion of tools :-) > > > yaws or mochiweb? > > mnesia or mongoDB? > > chicago boss or ...? > > XML or JSon? > > intellij idea or eclipse? > > and before i buy a server, Win or Linux or ...? > > > while whatever i study seems ok, it is all taking a lot of time and > keeping > > me from coding in erlang. > > > there is some good info on the web, but i value your opinions more. > > understanding you will be required to maintain your app, if you were > > starting from scratch, which choice would you make first? > > I'd turn the problem around. What are you trying to do, and why are > you set on using Erlang for it? "Learning Erlang" is a perfectly > acceptable response, but it does color the discussion some. > > I've been doing "web stuff" for nearly 20 years, and here's my opinion > about the state of Erlang and "web stuff": > > * It's got most of the pieces you need. > > * There is no really good framework that puts them all together in a > decent way to get started. Chicago Boss was a valiant attempt at > this, but... it's got some warts. > > * As an example of the kind of thing you'll have to learn about and > put together yourself, consider using a database: at a minimum, you're > going to want to integrate something like fuse and poolboy to make it > work at any kind of scale, and make it work robustly. > > * The bits and pieces I would use: cowboy web server, Postgres > database with epgsql, erlydtl for templates, jiffy for json, poolboy, > fuse, lager, recon, relx and a few other bits and pieces. > > * If putting all that together is not your thing, and you are more > interested in getting something up and running as soon as possible, > you might look at other languages. Elixir's Phoenix framework runs on > the same VM as Erlang. Going further afield, you have all kinds of > choices, which have their own advantages and disadvantages, depending > on what you want to accomplish. I'm personally a fan of Ruby on Rails > for how much stuff you can do by including various libraries. People > have managed to build businesses on PHP, Node.js, Java, Python, Perl, > Tcl and all kinds of other systems. > > * Don't buy a computer, rent a VPS via something like Linode, and run > Linux (or maybe some BSD system if you feel adventurous). > > -- > David N. Welton > > http://www.welton.it/davidw/ > > http://www.dedasys.com/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela.andin@REDACTED Mon Feb 16 22:34:53 2015 From: ingela.andin@REDACTED (Ingela Andin) Date: Mon, 16 Feb 2015 22:34:53 +0100 Subject: [erlang-questions] SSL performance In-Reply-To: References: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> <54DB7C58.4010203@ninenines.eu> <314615231.2183310.1423671054408.JavaMail.zimbra@tpip.net> <1496919824.2183311.1423671102176.JavaMail.zimbra@tpip.net> Message-ID: Hi! There is a reason for using only one process, as receiving of a message can change the conditions for sending, but yes we are aware of this causing potential problems. And we are considering ways of handling this in other ways, although we have a lot to do at the moment so no promises on when the official solution the solution will be released. Regards Ingela Erlang/OTP team - Ericsson AB 2015-02-11 17:30 GMT+01:00 Sean Cribbs : > It doesn't sound like you're running into this, but we recently found > there to be a potential deadlock in the ssl connection under high > throughput, patched on our fork of OTP here: > > > https://github.com/basho/otp/commit/e237383fe002af4f63f8419b35bac6f435856a38 > > On Wed, Feb 11, 2015 at 10:11 AM, Andreas Schultz > wrote: > >> >> >> ----- On 11 Feb, 2015, at 16:59, Lo?c Hoguin essen@REDACTED wrote: >> >> > On 02/11/2015 04:29 PM, Andreas Schultz wrote: >> >> The cause for this is not the cryptographic library, but Erlang's >> interface to >> >> it. >> >> Erlang's crypto application uses a non-optimized OpenSSL API to >> execute the AES >> >> encryption, while enacl seems to uses an highly optimized version. >> >> >> >> Normally when doing AES, you first have to schedule the key, creating >> an >> >> encryption >> >> context and then reuse that context for every block. Since the crypto >> >> application >> >> doesn't have stream_cipher versions of AES, it has to go through the >> key >> >> scheduling >> >> on every invocation (every block). Also, OpenSSL can use assembler >> optimized AES >> >> functions on modern CPU's, but those are only available when OpenSSL's >> EVP >> >> interfaces >> >> are used. Erlang's crypto does not use those. >> > >> > I have seen some work around EVP in the past few months. Is this not >> > what you are talking about? >> > >> > commit 425a34001fdd5de8396c5c9903f4f38a9d49a15c >> > Author: Alex Wilson >> > Date: Thu Oct 9 21:39:29 2014 +1000 >> > >> > crypto: use EVP for AES-CBC >> > >> > This enables the use of hardware acceleration for AES crypto >> > on newer Intel CPUs (AES-NI), among other platforms. >> >> That is a good step in the right direction. Still, it has to recreate the >> EVP crypto context for every invocation. There was a discussion about >> keeping the EVP context between invocations and use the crypto >> stream_encrypt/decrypt instead. That would eliminate the overhead of the >> context creation between calls. >> >> Andreas >> >> > Cheers. >> > >> > -- >> > Lo?c Hoguin >> > http://ninenines.eu >> >> -- >> -- >> Dipl. Inform. >> Andreas Schultz >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > > > -- > Sean Cribbs > Sr. Software Engineer > Basho Technologies, Inc. > http://basho.com/ > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ingela.andin@REDACTED Mon Feb 16 22:40:46 2015 From: ingela.andin@REDACTED (Ingela Andin) Date: Mon, 16 Feb 2015 22:40:46 +0100 Subject: [erlang-questions] SSL performance In-Reply-To: <1496919824.2183311.1423671102176.JavaMail.zimbra@tpip.net> References: <1128919905.2182931.1423668583231.JavaMail.zimbra@tpip.net> <54DB7C58.4010203@ninenines.eu> <314615231.2183310.1423671054408.JavaMail.zimbra@tpip.net> <1496919824.2183311.1423671102176.JavaMail.zimbra@tpip.net> Message-ID: Hi! We do welcome a pull request to improve crypto internals. If you want to change the API remember that backwards-compatibility is important to us. So please communicate with us for any API changes, even additions before putting too much effort into writing test cases, documentation etc. Regards Ingela Erlang/OTP team - Ericsson AB 2015-02-11 17:11 GMT+01:00 Andreas Schultz : > > > ----- On 11 Feb, 2015, at 16:59, Lo?c Hoguin essen@REDACTED wrote: > > > On 02/11/2015 04:29 PM, Andreas Schultz wrote: > >> The cause for this is not the cryptographic library, but Erlang's > interface to > >> it. > >> Erlang's crypto application uses a non-optimized OpenSSL API to execute > the AES > >> encryption, while enacl seems to uses an highly optimized version. > >> > >> Normally when doing AES, you first have to schedule the key, creating an > >> encryption > >> context and then reuse that context for every block. Since the crypto > >> application > >> doesn't have stream_cipher versions of AES, it has to go through the key > >> scheduling > >> on every invocation (every block). Also, OpenSSL can use assembler > optimized AES > >> functions on modern CPU's, but those are only available when OpenSSL's > EVP > >> interfaces > >> are used. Erlang's crypto does not use those. > > > > I have seen some work around EVP in the past few months. Is this not > > what you are talking about? > > > > commit 425a34001fdd5de8396c5c9903f4f38a9d49a15c > > Author: Alex Wilson > > Date: Thu Oct 9 21:39:29 2014 +1000 > > > > crypto: use EVP for AES-CBC > > > > This enables the use of hardware acceleration for AES crypto > > on newer Intel CPUs (AES-NI), among other platforms. > > That is a good step in the right direction. Still, it has to recreate the > EVP crypto context for every invocation. There was a discussion about > keeping the EVP context between invocations and use the crypto > stream_encrypt/decrypt instead. That would eliminate the overhead of the > context creation between calls. > > Andreas > > > Cheers. > > > > -- > > Lo?c Hoguin > > http://ninenines.eu > > -- > -- > Dipl. Inform. > Andreas Schultz > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nayibor@REDACTED Tue Feb 17 04:40:02 2015 From: nayibor@REDACTED (Nuku Ameyibor) Date: Tue, 17 Feb 2015 03:40:02 +0000 Subject: [erlang-questions] Behaviours in a module Message-ID: Hello List , Hope everyone is cool. i noticed a few patterns in some tutorials i was going through and wanted some insight . How many application behaviors can you attach to a single module and how does this affect the behavior of the module . i saw these examples -module(a). -behaviour(application). -export([start/2, stop/1, start_pool/3) start(normal, _Args) -> ppool_supersup:start_link(). ..... %%%%and b below *-*module(b). -behaviour(application). -behaviour(supervisor). -export([start/2, stop/1]). -export([init/1]). start() ->application:start(?MODULE). ....... in module a i know the start function will call the top level supervisor and the top level supervisor will start itself and possibly children etc... in module b i know the start function will be run and run application:start(?module) . what happens after that because the function seems to be calling itself which is causing me to scratch my head . what happens to the supervisor behavior also . can you put different behaviors into a single module and evoke them and make that one module have all the behaviours eg. can a single module be a gen_server,supervisor or are there some special instances where this is allowed .(genserver and supervisor both have one init function so i was beginning to doubt this but what if your behaviors have different names): i.e. create your own custom behaviours an unrelated question does a socket closing send a message to the controlling process immediately . i get the {tcp_closed, _Socket} message only when i am sending a message to a closed socket . it there a way the controlling process is immediately notified of a closed socket and not nessaringly when you tring sending a message to it thanks !!! -------------- next part -------------- An HTML attachment was scrubbed... URL: From vances@REDACTED Tue Feb 17 05:30:37 2015 From: vances@REDACTED (Vance Shipley) Date: Tue, 17 Feb 2015 10:00:37 +0530 Subject: [erlang-questions] Behaviours in a module In-Reply-To: References: Message-ID: I don't see any examples of multiple behaviours in OTP today however I do remember there being a few cases at one time. Basically if there is no conflict in callback name/arity (*) grep --recursive --count --files-with-matches '^-behaviour(' otp_src_17.3 | grep '[2-9]$' On Tue, Feb 17, 2015 at 9:10 AM, Nuku Ameyibor wrote: > How many application behaviors can you attach to a single module and how > does this affect the behavior of the module . If there is no conflict in callbacks' name/arity you can include multiple behaviours. I don't see any examples of multiple behaviours in OTP today however I do remember there being a few cases at one time where application and supervisor behaviours appeared in one module. > can you put different behaviors into a single module and evoke them and make > that one module have all the behaviours eg. can a single module be a > gen_server,supervisor or are there some special instances where this is > allowed .(genserver and supervisor both have one init function so i was > beginning to doubt this but what if your behaviors have different names): Since gen_server and supervisor both call init/1 you have a potential conflict. You could have the different behaviours handled in separate clauses, based on the argument, thereby avoiding a conflict. This would really be an exercise in obfuscation however. Don't do it. > i.e. create your own custom behaviours Custom behaviours have been supported for quite some time. Basically all a behaviour is is a design pattern for modules you write. By using the -behaviour attribute in your (callback) module you are declaring it to match the pattern. During compilation erl_lint checks to see that your callback module exports the required functions. You may create your own behaviours by including a -callback attribute in the module which implements the pattern (main loop), the name of that module isis used in the -behaviour attribute of your callback module. http://www.erlang.org/doc/design_principles/spec_proc.html#behaviours -- -Vance From rizkhan@REDACTED Tue Feb 17 07:47:32 2015 From: rizkhan@REDACTED (Rizwan Khan) Date: Tue, 17 Feb 2015 11:47:32 +0500 Subject: [erlang-questions] Erlang based C2ISR system Message-ID: Any one knows if Erlang is being used anywhere for Command and Control or ISR systems which are normally for the armed forces. I am not too sure if that would be a good fit either. May be in terms for distributed computing and surely not for image processing related applications. Rizwan Khan -------------- next part -------------- An HTML attachment was scrubbed... URL: From zxq9@REDACTED Tue Feb 17 10:05:55 2015 From: zxq9@REDACTED (zxq9) Date: Tue, 17 Feb 2015 18:05:55 +0900 Subject: [erlang-questions] Erlang based C2ISR system In-Reply-To: References: Message-ID: <1488951.nvtsoKpDl8@changa> On 2015?2?17? ??? 11:47:32 Rizwan Khan wrote: > Any one knows if Erlang is being used anywhere for Command and Control or > ISR systems which are normally for the armed forces. > > I am not too sure if that would be a good fit either. May be in terms for > distributed computing and surely not for image processing related > applications. A somewhat long-winded response follows, much of it anecdotal. I'm trying to give enough background for the OP to understand the situation that exists at the C2 level, the tactical level, and what I have seen in a C2&T project I've worked on, and what I have externally observed about another very similar one. ~~~~~~ I doubt it is. In any case, of the bajillion or so supposedly interoperable C2 systems I ever took the time to peek into, every one seemed to be written against a different combination of language/platform/environment assumptions. Whether or not Erlang is a good fit for C2 (and in many cases it certainly may be), it seems to have about zero mindshare within the military. At a larger TOC there was usually a guy or section whose task it was to aggregate data so various folks could access it or use it -- more often than not, though, a TOC (whether a FOB, JSOTF, JSOTF-forward, or an *actual* TOC) is a blackhole for information. In SF our 18E/F/Cs (or whoever on the team had significant computer knowledge and could work with the 18E) would deal with receiving, say, UAV imagery directly from the pilot's direct feed or (usually better) from whatever laptop software could talk to it, convert it to something he could send over the air, and relay it that way. Data from outside the team might be handled the same way (if there was time), but usually a one-off system existed for each type of asset we might be working with (like an application that handles one specific type of video from one particular source, an entire hardware-kit-in-a-suitcase for receiving P3 imagery live, a special video box with no digital output so we could (maybe) watch a particular feed, etc.) and very often there just isn't time to mess with aggregation in a useful way until long after the fun is over. Of course, at the TOC, where all the folks who don't actually do anything operational hang out, all sorts of data is supposedly aggregated -- but I've seen exactly zero evidence of that in practice. I suspect that roughly half the blame for the blackholiness of TOCs (and other echelons beyond reality in general) belongs to the bureaucratic sloth that manifests in any large, rigid organization, and the other half probably belongs to the fact that every single system is completely different from every other system (and that itself is a product of the nature of acquisitions within large bureaucracies). Sorting through all the miles of piles of data that pour in to a TOC after- the-fact is a much lower priority than ongoing operations (or than printing random memoranda about authorized holster models, etc.), so the monumental task of untangling the digital/analog Gordian Knot appears to rarely be undertaken in a serious way -- at least from what I witnessed. I don't think there is really any way around this, though the situation could certainly be a bit less ridiculous. So with that anecdotal picture in mind, the search for use cases of Erlang in C2 systems (of any kind) is either going to be extremely difficult (sifting through thousands of one-off systems by vendors reluctant to expose their tools), or purely academic. Colt is doing some interesting work on an integrated C2 system for the tactical level, but I don't think any Erlang is involved there (mostly C and Java, from the looks of it -- I've never looked inside, though). I was leading a project last year at a company developing a conceptually related system which had very different origins and a different focus (The company imploded midway through! Very frustrating!). While I was actually going to use Erlang for the (somewhat limited) tasks that existed server-side, much of the rest of the project code was C and Scala. A lot of what was required was either directly dependent on unique hardware or had to run on Android, everything required careful power usage, most of the system was peer-oriented up to a certain layer, and Erlang just did not fit most of the roles. Regards, -Craig From imantc@REDACTED Tue Feb 17 14:51:42 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 14:51:42 +0100 Subject: [erlang-questions] Process scope variable Message-ID: Does anyone see any benefit from process scope variables? E.g. a()-> From imantc@REDACTED Tue Feb 17 14:55:31 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 14:55:31 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: Does anyone see any benefit from process scope variables? E.g. a()-> A = 10, b(). b()-> B = A + 1. If unset variable is referenced, an error is raised. If set process variable is assigned to (and does not pattern match), an error is raised. This way, there is no need to pass a bunch of static variables around. ? From dmytro.lytovchenko@REDACTED Tue Feb 17 14:58:31 2015 From: dmytro.lytovchenko@REDACTED (Dmytro Lytovchenko) Date: Tue, 17 Feb 2015 14:58:31 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: You're asking for trouble here -- global variables will complicate your code and bring in hard to track errors. On the other hand, carrying few variables in parameters or carrying a state record will make changes performed by your code very much visible and easy to track using only your eyes. But anyway, if you very much want that -- process global variables can be set by erlang:put() and can be read by erlang:get(). Enjoy your heisenbugs. On Tue, Feb 17, 2015 at 2:55 PM, Imants Cekusins wrote: > Does anyone see any benefit from process scope variables? > > E.g. > a()-> > A = 10, > b(). > > b()-> > B = A + 1. > > If unset variable is referenced, an error is raised. > > If set process variable is assigned to (and does not pattern match), > an error is raised. > > > This way, there is no need to pass a bunch of static variables around. > > ? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Tue Feb 17 15:00:44 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 15:00:44 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: > process global variables can be set by erlang:put() and can be read by erlang:get(). cheers for the hint ;) I'll try it and see if it makes life any easier. From dangud@REDACTED Tue Feb 17 15:11:04 2015 From: dangud@REDACTED (Dan Gudmundsson) Date: Tue, 17 Feb 2015 15:11:04 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: Why not a() -> 10. b() -> a() + 1. On Tue, Feb 17, 2015 at 3:00 PM, Imants Cekusins wrote: > > process global variables can be set by erlang:put() and can be read by > erlang:get(). > > cheers for the hint ;) > > I'll try it and see if it makes life any easier. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dangud@REDACTED Tue Feb 17 15:17:04 2015 From: dangud@REDACTED (Dan Gudmundsson) Date: Tue, 17 Feb 2015 15:17:04 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: Hmm missed something there didn't I.. With funs you can do: a() -> A = 10, B = fun() -> A + 1 end, B(). On Tue, Feb 17, 2015 at 3:11 PM, Dan Gudmundsson wrote: > Why not > > a() -> 10. > > b() -> a() + 1. > > On Tue, Feb 17, 2015 at 3:00 PM, Imants Cekusins wrote: > >> > process global variables can be set by erlang:put() and can be read by >> erlang:get(). >> >> cheers for the hint ;) >> >> I'll try it and see if it makes life any easier. >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Tue Feb 17 15:18:27 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 15:18:27 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: > Why not a() -> 10. > b() -> a() + 1. Let's say, there is a long chain of function calls. Some of them need A, some of them don't. Let A be clearly static, defined early in the process. Using process dict, I will pass only relevant vars from fun to fun, not messages to some other funs down the line. From imantc@REDACTED Tue Feb 17 15:33:19 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 15:33:19 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: > With funs you can do: > a() -> > A = 10, > B = fun() -> A + 1 end, > B(). closure, isn't it? yes it is helpful. well the idea is not to eliminate function arguments but pass only args specific to the fun. also, please note that process dict allows overriding. I was thinking more in terms of static var - same as in function scope. Well it only takes a util fun to explicitly allow or disallow override. Can even raise a stacktrace to show where in the code the var was set. why didn't I ask a while ago.. From zxq9@REDACTED Tue Feb 17 16:51:11 2015 From: zxq9@REDACTED (zxq9) Date: Wed, 18 Feb 2015 00:51:11 +0900 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: <3557038.bkb3CVCkxg@changa> On 2015?2?17? ??? 15:18:27 Imants Cekusins wrote: > > Why not a() -> 10. > > b() -> a() + 1. > > Let's say, there is a long chain of function calls. Some of them need > A, some of them don't. > > Let A be clearly static, defined early in the process. > > Using process dict, I will pass only relevant vars from fun to fun, > not messages to some other funs down the line. I think part of the conceptual problem is that you're missing the distinction between messages and arguments -- they are not the same thing. In any case, someone has already mentioned the process dictionary, and given a tongue-in-cheek warning about its use. The former provides an exact implementation of the functionality you seem to desire, the latter was a rather understated and brief version of the obligatory warning against abandoning one of Erlang's greatest benefits. -Craig From nayibor@REDACTED Tue Feb 17 17:18:00 2015 From: nayibor@REDACTED (Nuku Ameyibor) Date: Tue, 17 Feb 2015 08:18:00 -0800 Subject: [erlang-questions] Behaviours in a module Message-ID: <-6783339599502666261@unknownmsgid> Thanks for the clarifications Van . From: Vance Shipley Sent: ?17/?02/?2015 04:30 To: Nuku Ameyibor Cc: erlang questions Subject: Re: [erlang-questions] Behaviours in a module I don't see any examples of multiple behaviours in OTP today however I do remember there being a few cases at one time. Basically if there is no conflict in callback name/arity (*) grep --recursive --count --files-with-matches '^-behaviour(' otp_src_17.3 | grep '[2-9]$' On Tue, Feb 17, 2015 at 9:10 AM, Nuku Ameyibor wrote: > How many application behaviors can you attach to a single module and how > does this affect the behavior of the module . If there is no conflict in callbacks' name/arity you can include multiple behaviours. I don't see any examples of multiple behaviours in OTP today however I do remember there being a few cases at one time where application and supervisor behaviours appeared in one module. > can you put different behaviors into a single module and evoke them and make > that one module have all the behaviours eg. can a single module be a > gen_server,supervisor or are there some special instances where this is > allowed .(genserver and supervisor both have one init function so i was > beginning to doubt this but what if your behaviors have different names): Since gen_server and supervisor both call init/1 you have a potential conflict. You could have the different behaviours handled in separate clauses, based on the argument, thereby avoiding a conflict. This would really be an exercise in obfuscation however. Don't do it. > i.e. create your own custom behaviours Custom behaviours have been supported for quite some time. Basically all a behaviour is is a design pattern for modules you write. By using the -behaviour attribute in your (callback) module you are declaring it to match the pattern. During compilation erl_lint checks to see that your callback module exports the required functions. You may create your own behaviours by including a -callback attribute in the module which implements the pattern (main loop), the name of that module isis used in the -behaviour attribute of your callback module. http://www.erlang.org/doc/design_principles/spec_proc.html#behaviours -- -Vance From hm@REDACTED Tue Feb 17 17:28:09 2015 From: hm@REDACTED (=?UTF-8?Q?H=C3=A5kan_Mattsson?=) Date: Tue, 17 Feb 2015 17:28:09 +0100 Subject: [erlang-questions] new user want to encode & decode h248 protocol In-Reply-To: References: Message-ID: The Megaco app is a beast and it is perhaps not the one that I would start with if I was going to learn Erlang from scratch. There are however several good books explaining Erlang. Read some of them and get hands on with their exercises. "Learn you some Erlang" is a very good on-line source. Once you are a little bit familiar with Erlang, I would recommend you to run the simple mg/mgc examples in the Megaco app. Use the Erlang debugger to follow the call flow from socket to socket. When you got the overall picture you can inspect the transport callback modules in Megaco (TCP and UDP) to see how they are reading packets. You can either use them or roll your own. Once you have read a packet you can feed it into a suitable decoder that fit your needs. There are several decoders provided, both textual and binary. Good luck! /H?kan On Sat, Feb 14, 2015 at 7:35 PM, ?? wrote: > Hi > > I'm new user of erlang, I want to encode & decode h248 packets captured > from network. I want to use open source h248 protocol stack to complete > this work. Use google, I found erlang/otp can do this, but my program > experience is c++, so I have to learn erlang for this problem. In erlang's > megaco document, the example is about how to implement mg/mgc, but I need > not to implement mg/mgc, I only need encode & decode h248 protocol, and > recover the calling procedure in human readable format. > > My problem is: how to use erlang's lib to encode & decode h248 packets > captured from network ( use tcpdump), and recover the calling procedure? > Please give me some hints about this ( as simple as possible, because I > have learned erlang only one day ). > > Thank you very much! > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Tue Feb 17 18:08:37 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 18:08:37 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <3557038.bkb3CVCkxg@changa> References: <3557038.bkb3CVCkxg@changa> Message-ID: > you're missing the distinction between messages and arguments -- they are not the same thing. I used the word "message" in a misleading way. I did not mean "message" as erlang message sent to another process. simply alleged to "message" (a "tweet" if you prefer) passed from person A to person B intended for person C, from function to function in this case, an arg passed to fun z() like this: a()-> S = #state{}, b(S). b(S)-> c(S). ... z(S)-> Z = S#state.some_var. an arg S passed to another fun X, which fun X may or may not use, simply pass it to the next fun and so on. this state passing clutters the code and makes refactoring difficult. I prefer to only pass the args the fun actually needs. If some other fun down the line needs the state, let it get it directly. common state could be dangerous if simultaneous state modification could happen. But in Erlang this does not happen, does it? each single process is a single thread, isn't it? From zxq9@REDACTED Tue Feb 17 18:37:00 2015 From: zxq9@REDACTED (zxq9) Date: Wed, 18 Feb 2015 02:37 +0900 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <3557038.bkb3CVCkxg@changa> Message-ID: <11219577.5VlZ0ycJe9@changa> On 2015?2?17? ??? 18:08:37 you wrote: > > you're missing the distinction between messages and arguments -- they are > > not the same thing. > I used the word "message" in a misleading way. I did not mean > "message" as erlang message sent to another process. simply alleged to > "message" (a "tweet" if you prefer) passed from person A to person B I don't prefer. Its still not the same thing. > this state passing clutters the code and makes refactoring difficult. > I prefer to only pass the args the fun actually needs. If some other > fun down the line needs the state, let it get it directly. The goal is to be explicit, so that you can look at exactly, and only, the inputs to a function on a single call and be able to know/test its outcome precisely unless it has side effects. When you say "let it get it directly" you are introducing a side effect, whether that is fetching something from the process dictionary (which is at least data internal to the process) or fetching data from an external resource, it is not a value that sticks out the moment something crashes because of unanticipated data used in the function somewhere because it was *not* one of its inputs. Even if debugging and readability were the only reasons for this, they would be good enough reasons to handle as much data within a process as I could as arguments instead of sideband acquisitions of additional non-argument data mid-stride through stage V of N expressions in function X of Y in a chain of calls. This style of thinking avoids subtly putting too much explicit responsibility in a single function. Instead of getting called, fetching a value, performing some computation, sending a response to the data fetch source, and returning a value in a single monolithic function ("OK, so it was called here with X and Y but it crashed... hmmm... Oh, Z? Where did that come from? Oh, fetching from source Q... wait, what part of that didn't work out? Oh, that was the process dictionary? But it wasn't changed yet, so not fetched yet, that's another place... mmm..." <- waste of the only resource you were born with), have a function that does each of these, and a single function that wraps the concept so you can at least keep track of what is going on. A (very rough heuristic) symptom is frequently noticing a few >20 expression functions instead of several <10 expression functions. If you find yourself writing an excessive number of functions that simply receive arguments to pass them through it may be a good idea to ask yourself why your programs are winding up this way before you start hunting for ways to dance around the design decisions that underly the system. Sometimes it isn't easy to avoid passing, say, a gen_server's #state (or something similar) along here and there, but usually refactoring for functional generalization also winds up yielding code that does a lot less argument passthrough. From imantc@REDACTED Tue Feb 17 19:04:07 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 19:04:07 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <11219577.5VlZ0ycJe9@changa> References: <3557038.bkb3CVCkxg@changa> <11219577.5VlZ0ycJe9@changa> Message-ID: let's say, the code works, I understand it and can debug it. However one problem I do face is slow speed of refactoring without state. Refactoring is the right thing to do, so I am trying to do something about it. From imantc@REDACTED Tue Feb 17 21:38:32 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 21:38:32 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <11219577.5VlZ0ycJe9@changa> References: <3557038.bkb3CVCkxg@changa> <11219577.5VlZ0ycJe9@changa> Message-ID: you are right. "state" would introduce problems. going to "state" (in any form) for values would also slow things down when the code runs. thank you for warning, everyone. how about those process scope variables though? :-P more reliable than process dict. same principles as function scope variables: immutable, gc'ed when the process finishes. would noone else use them? From gguthrie@REDACTED Tue Feb 17 19:01:11 2015 From: gguthrie@REDACTED (Gordon Guthrie) Date: Tue, 17 Feb 2015 18:01:11 +0000 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <3557038.bkb3CVCkxg@changa> Message-ID: <5DC77382-1CD0-4216-965C-BD6BC8CCF9BD@basho.com> Imants > Quite simply, there is a lot of the code. It does a lot, too. The code > is of a size normally produced by a team of coders. The fact that I > work on it without help, and refactor it, and it works, may be a good > indicator. I have been in this situation - the answer is to refactor it into ?pure? and ?impure? functions and take the hit on common state up front. Every time you dip into the process dictionary that is another hard-to-reason-about code complexity - you are making it worse, not fixing it? (although it might seem that you are fixing it) Gordon > Le 17 f?vr. 2015 ? 17:44, Imants Cekusins a ?crit : > > Hi Gordon, > > Most of the code I write is about logic, branching. > > Despite what may appear (I am not afraid to write before I think > carefully because I do not write to impress, I write when I feel > like, that's all), I did gain considerable experience in producing > robust working code in situations when colleagues and sometimes > managers had simply given up. > > The state referred to could be inputs, an accumulated result of input > processing, parent process info, current stage. > > Quite simply, there is a lot of the code. It does a lot, too. The code > is of a size normally produced by a team of coders. The fact that I > work on it without help, and refactor it, and it works, may be a good > indicator. > > Frequent refactoring is caused by the code growing organically rather > than carefully planned. The main reason being: I do not think twice > before changing requirements, specs. Also, whenever I get an idea, I > refactor as much as necessary. > > Basically, there is a lot of work. Common state will help me speed it up. > > I'll get there ;) From felixgallo@REDACTED Tue Feb 17 22:21:14 2015 From: felixgallo@REDACTED (Felix Gallo) Date: Tue, 17 Feb 2015 13:21:14 -0800 Subject: [erlang-questions] Process scope variable In-Reply-To: <5DC77382-1CD0-4216-965C-BD6BC8CCF9BD@basho.com> References: <3557038.bkb3CVCkxg@changa> <5DC77382-1CD0-4216-965C-BD6BC8CCF9BD@basho.com> Message-ID: This thread has me wondering exactly what optimizations, if any, BEAM tries to make on state being passed in OTP behavior callbacks. Naively I would assume that such an optimization would be pretty cheap and high value, and so someone would have thought of that and implemented something such that the last argument to an OTP callback is not just recopied onto the stack every time but rather kept somewhere special and referenced. Maybe I should go look at the source. On Tue, Feb 17, 2015 at 10:01 AM, Gordon Guthrie wrote: > Imants > > > Quite simply, there is a lot of the code. It does a lot, too. The code > > is of a size normally produced by a team of coders. The fact that I > > work on it without help, and refactor it, and it works, may be a good > > indicator. > > I have been in this situation - the answer is to refactor it into ?pure? > and ?impure? functions and take the hit on common state up front. > > Every time you dip into the process dictionary that is another > hard-to-reason-about code complexity - you are making it worse, not fixing > it? (although it might seem that you are fixing it) > > Gordon > > > Le 17 f?vr. 2015 ? 17:44, Imants Cekusins a ?crit : > > > > Hi Gordon, > > > > Most of the code I write is about logic, branching. > > > > Despite what may appear (I am not afraid to write before I think > > carefully because I do not write to impress, I write when I feel > > like, that's all), I did gain considerable experience in producing > > robust working code in situations when colleagues and sometimes > > managers had simply given up. > > > > The state referred to could be inputs, an accumulated result of input > > processing, parent process info, current stage. > > > > Quite simply, there is a lot of the code. It does a lot, too. The code > > is of a size normally produced by a team of coders. The fact that I > > work on it without help, and refactor it, and it works, may be a good > > indicator. > > > > Frequent refactoring is caused by the code growing organically rather > > than carefully planned. The main reason being: I do not think twice > > before changing requirements, specs. Also, whenever I get an idea, I > > refactor as much as necessary. > > > > Basically, there is a lot of work. Common state will help me speed it up. > > > > I'll get there ;) > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From e@REDACTED Tue Feb 17 22:40:05 2015 From: e@REDACTED (e@REDACTED) Date: Tue, 17 Feb 2015 22:40:05 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: <54E3B535.70503@bestmx.net> > Does anyone see any benefit from process scope variables? it is called "process dictionary" and it is a profound source of bugs and pain. it is useful in some cases, but coding is easier and cleaner without it. nevertheless, a living example, how do i use the process dictionary: module "game.erl" represents a game process, few player processes are talking to the game process. init( PlayerNames, PlayerRatings, PlayerPIDs ) -> % store useless info in the process dictionary for future use put( 'players', PlayerRatings, PlayerNames ) % store useful info in the stack main_loop( Status, PlayerPIDs ) . main_loop( bla bla bla ) -> ... ; % this is the end of the game % the only place we actually need those PlayerRating and stuff main_loop( Status = 'end_of_game', PlayerPIDs ) -> PlayerInfo = get( 'players' ) update_player_ratings( PlayerInfo ) ... . as you see i decided to use process dictionary for "long-term" storage of the information that is NEVER ALTERED during the lifetime of the process -- seems to me quite appropriate usecase for the process dictionary. but i am not an Erlang guru, i am just using common sense. similarly i use the process dictionary in genetic algorithms for storing a process's genome. it seemed to me totally natural -- use the global scope of the process for storing some INTRINSIC process's data. From ryankbrown@REDACTED Tue Feb 17 22:55:55 2015 From: ryankbrown@REDACTED (Ryan Brown) Date: Tue, 17 Feb 2015 14:55:55 -0700 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 Message-ID: Hello all, I am in the process of upgrading a legacy application from R15B01 to R16B03 in order to get SHA 384 support. However, I am getting an error creating my CMAC from the library located here: https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl For the life of me I cannot find the root cause. I am just receiving a badarg error pointing to line 74. Any guidance would be greatly appreciated. Thank you. -------------- next part -------------- An HTML attachment was scrubbed... URL: From garry@REDACTED Tue Feb 17 23:00:22 2015 From: garry@REDACTED (Garry Hodgson) Date: Tue, 17 Feb 2015 17:00:22 -0500 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <3557038.bkb3CVCkxg@changa> <11219577.5VlZ0ycJe9@changa> Message-ID: <54E3B9F6.4070105@research.att.com> On 2/17/15 3:38 PM, Imants Cekusins wrote: > how about those process scope variables though? :-P > > more reliable than process dict. same principles as function scope > variables: immutable, gc'ed when the process finishes. > > would noone else use them? not me. i learned to avoid global variables decades ago. From imantc@REDACTED Tue Feb 17 23:06:40 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 23:06:40 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E3B535.70503@bestmx.net> References: <54E3B535.70503@bestmx.net> Message-ID: > "process dictionary" and it is a profound source of bugs and pain does it cause problems because it is mutable? what about values which never change? as in your example. or, say, a parent pid? naturally tied in to current thread scope, accessible from anywhere in the process. similar to application env variables, but for one process. and assignable from within the process. or when spawning the process. From felixgallo@REDACTED Tue Feb 17 23:10:56 2015 From: felixgallo@REDACTED (Felix Gallo) Date: Tue, 17 Feb 2015 14:10:56 -0800 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 In-Reply-To: References: Message-ID: I'm not super familiar with the crypto library, but it looks like its function signatures changed significantly between 15B01 and 16B03. In particular, it appears that some of the functions you are calling are no longer in the library, and have been replaced with equivalents. I suggest opening http://erldocs.com/R15B01/crypto/crypto.html and http://erldocs.com/R16B03/crypto/crypto.html and seeing if you can figure out where the changes occurred. I suspect those are the cause of your badargs. F. On Tue, Feb 17, 2015 at 1:55 PM, Ryan Brown wrote: > Hello all, > > I am in the process of upgrading a legacy application from R15B01 to > R16B03 in order to get SHA 384 support. However, I am getting an error > creating my CMAC from the library located here: > > https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl > > For the life of me I cannot find the root cause. I am just receiving a > badarg error pointing to line 74. > > Any guidance would be greatly appreciated. > > Thank you. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Tue Feb 17 23:11:38 2015 From: imantc@REDACTED (Imants Cekusins) Date: Tue, 17 Feb 2015 23:11:38 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E3B9F6.4070105@research.att.com> References: <3557038.bkb3CVCkxg@changa> <11219577.5VlZ0ycJe9@changa> <54E3B9F6.4070105@research.att.com> Message-ID: > not me. i learned to avoid global variables decades ago. mutable global vars are a pain alright. I avoid them, too. this one is not really a global one though. a within-process. and immutable. anyway, a very slim chance of it seeing the light. just a thought. From richard.youngkin@REDACTED Tue Feb 17 23:25:21 2015 From: richard.youngkin@REDACTED (Youngkin, Rich) Date: Tue, 17 Feb 2015 15:25:21 -0700 Subject: [erlang-questions] Why isn't 'EXIT' message being received/processed? Message-ID: Hi, I've got an app that spawn_links processes with trap_exit. I'm killing the linked processes but the monitoring process isn't always receiving the 'EXIT' message. Here are some code snippets: ... process_flag(trap_exit, true), link(Connection), link(Channel), ... loop(State) -> ... {'EXIT', What, Reason} -> do_something_smart(); ... Connection and Channel are a RabbitMQ connection and channel (although that's not necessarily important to know). I'm manually running "force close" on the connection via the RabbitMQ admin interface to trigger the 'EXIT'. In one case the 'EXIT' message is received and in the other case it isn't. Here are more code snippets to illustrate this (same loop/1 function as above): loop(#state{channel=Channel, delay_ack= DelayAck} = State) -> ... {#'basic.deliver'{delivery_tag=DeliveryTag}, Content} -> ... do something with the content case DelayAck of true -> timer:sleep(500), %% allow time for 'EXIT' to arrive in the mailbox before "ack_delivery" message self() ! {ack_delivery, Channel, DeliveryTag}, loop(State); _ -> amqp_channel:call(Channel, #'basic.ack'{delivery_tag=DeliveryTag}), loop(State) end; {ack_delivery, Channel, DeliveryTag} -> timer:sleep(50), %% ack delay amqp_channel:call(Channel, #'basic.ack'{delivery_tag=DeliveryTag}), loop(State); ... In the above snippet DelayAck specifies whether the actual ack happens immediately or as a result of sending another message through loop/1. When DelayAck is false the 'EXIT' message is received as expected. When DelayAck is true there is a sleep of 500ms in order to allow the 'EXIT' to arrive in the mailbox before the {ack_delivery, Channel, DeliveryTag} message. But in this case the 'EXIT' message isn't received. The process instead fails with a "noproc" when invoking amqp_channel:call/2 in {ack_delivery...}. This makes sense since the Channel is now invalid, but I did expect 'EXIT' to be received first thereby avoiding this failure. Increasing the sleep before sending the {ack_delivery...} message doesn't make any difference (except to delay the "noproc" failure). The behavior described in this paragraph is consistent across several test runs. What would explain why the 'EXIT' message isn't received (ahead of the ack_delivery message, or even at all) in the DelayAck case? Thanks, Rich -------------- next part -------------- An HTML attachment was scrubbed... URL: From n.oxyde@REDACTED Tue Feb 17 23:49:39 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Tue, 17 Feb 2015 23:49:39 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: <71FFEE4A-E5BA-4304-B69B-4B0153011966@gmail.com> Le 17 f?vr. 2015 ? 14:55, Imants Cekusins a ?crit : > Does anyone see any benefit from process scope variables? > > E.g. > a()-> > A = 10, > b(). > > b()-> > B = A + 1. > > If unset variable is referenced, an error is raised. > > If set process variable is assigned to (and does not pattern match), > an error is raised. > > > This way, there is no need to pass a bunch of static variables around. Just use a pmod [1]! le_malaise.erl: -module'le_malaise',[A]. -compile{parse_transform,pmod_pt}. -export[b/0]. b() -> A + 1. le_malade:erl. -module'le_malade'. -export[test/0]. test() -> (le_malaise:new(10)):b(). [1] https://github.com/erlang/pmod_transform From imantc@REDACTED Wed Feb 18 00:00:25 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 00:00:25 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <71FFEE4A-E5BA-4304-B69B-4B0153011966@gmail.com> References: <71FFEE4A-E5BA-4304-B69B-4B0153011966@gmail.com> Message-ID: Salut Anthony, merci pour l'id?e. Je pense que je vais essayer de stocker des vars dans la base de m?moire. Je aime tout simplement le motif ?constructeur? de la POO. a(Ref), b(Ref), c(Ref), comme ?a. Je passe beaucoup trop de temps ? v?rifier ce qui args de passer ? une fonction et ce qui args - pour retourner. bonne nuit From ryankbrown@REDACTED Wed Feb 18 00:27:26 2015 From: ryankbrown@REDACTED (Ryan Brown) Date: Tue, 17 Feb 2015 16:27:26 -0700 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 In-Reply-To: References: Message-ID: Thank you Felix. It looks like the aes_cbc_128_encrypt method is gone so I changed all to use crypto:block_encrypt(aes_cbc128, Key, IV, ToBeEncrypted) But alas, I'm still seeing the same error. On Tue, Feb 17, 2015 at 3:10 PM, Felix Gallo wrote: > I'm not super familiar with the crypto library, but it looks like its > function signatures changed significantly between 15B01 and 16B03. In > particular, it appears that some of the functions you are calling are no > longer in the library, and have been replaced with equivalents. > > I suggest opening > > http://erldocs.com/R15B01/crypto/crypto.html > > and > > http://erldocs.com/R16B03/crypto/crypto.html > > and seeing if you can figure out where the changes occurred. I suspect > those are the cause of your badargs. > > F. > > On Tue, Feb 17, 2015 at 1:55 PM, Ryan Brown wrote: > >> Hello all, >> >> I am in the process of upgrading a legacy application from R15B01 to >> R16B03 in order to get SHA 384 support. However, I am getting an error >> creating my CMAC from the library located here: >> >> https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl >> >> For the life of me I cannot find the root cause. I am just receiving a >> badarg error pointing to line 74. >> >> Any guidance would be greatly appreciated. >> >> Thank you. >> >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Feb 18 00:43:21 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 18 Feb 2015 12:43:21 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: <130270E0-6C99-4677-92D0-9DBE6BA756E7@cs.otago.ac.nz> On 18/02/2015, at 2:55 am, Imants Cekusins wrote: > Does anyone see any benefit from process scope variables? No. We already have the process dictionary, which is exactly that. > > E.g. > a()-> > A = 10, > b(). > > b()-> > B = A + 1. It's a good thing I haven't had any lunch yet, or I'd have a hard time keeping it down at this point. However, a() -> put('A', 10), b(). b() -> put('B', get('A')+1). > This way, there is no need to pass a bunch of static variables around. I'm not sure what you mean by "static variables". From imantc@REDACTED Wed Feb 18 01:06:54 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 01:06:54 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <130270E0-6C99-4677-92D0-9DBE6BA756E7@cs.otago.ac.nz> References: <130270E0-6C99-4677-92D0-9DBE6BA756E7@cs.otago.ac.nz> Message-ID: Richard, this was a very simplified example. by "static" I meant immutable. yes, "static" can mean various things. in this case it is a misnomer. enjoy your lunch. ;) From felixgallo@REDACTED Wed Feb 18 01:21:26 2015 From: felixgallo@REDACTED (Felix Gallo) Date: Tue, 17 Feb 2015 16:21:26 -0800 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 In-Reply-To: References: Message-ID: I made your same changes to the module, and also added the following function to the module: test() -> Key = <<1:128>>, Data = <<1:128>>, generate_tag_aes_cbc_128(Key, Data). and when run in a shell: Eshell V6.1 (abort with ^G) 1> c(omac1),l(omac1),omac1:test(). <<173,219,62,66,7,255,149,96,196,74,41,116,238,229,211,35>> this appears to work (at least, it doesn't crash with badarg. I don't know whether the data is correct). Are you sure your aes key is 128, 192, or 256 bits long? It's possible the crypto module is throwing badarg when it detects an improper length key. On Tue, Feb 17, 2015 at 3:27 PM, Ryan Brown wrote: > Thank you Felix. It looks like the aes_cbc_128_encrypt method is gone so I > changed all to use crypto:block_encrypt(aes_cbc128, Key, IV, ToBeEncrypted) > > But alas, I'm still seeing the same error. > > On Tue, Feb 17, 2015 at 3:10 PM, Felix Gallo wrote: > >> I'm not super familiar with the crypto library, but it looks like its >> function signatures changed significantly between 15B01 and 16B03. In >> particular, it appears that some of the functions you are calling are no >> longer in the library, and have been replaced with equivalents. >> >> I suggest opening >> >> http://erldocs.com/R15B01/crypto/crypto.html >> >> and >> >> http://erldocs.com/R16B03/crypto/crypto.html >> >> and seeing if you can figure out where the changes occurred. I suspect >> those are the cause of your badargs. >> >> F. >> >> On Tue, Feb 17, 2015 at 1:55 PM, Ryan Brown wrote: >> >>> Hello all, >>> >>> I am in the process of upgrading a legacy application from R15B01 to >>> R16B03 in order to get SHA 384 support. However, I am getting an error >>> creating my CMAC from the library located here: >>> >>> https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl >>> >>> For the life of me I cannot find the root cause. I am just receiving a >>> badarg error pointing to line 74. >>> >>> Any guidance would be greatly appreciated. >>> >>> Thank you. >>> >>> >>> >>> _______________________________________________ >>> erlang-questions mailing list >>> erlang-questions@REDACTED >>> http://erlang.org/mailman/listinfo/erlang-questions >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Feb 18 01:31:05 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 18 Feb 2015 13:31:05 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <3557038.bkb3CVCkxg@changa> Message-ID: <7DB878F3-7882-450F-959C-BFDDC9217DF5@cs.otago.ac.nz> On 18/02/2015, at 6:08 am, Imants Cekusins wrote: >> you're missing the distinction between messages and arguments -- they are not the same thing. > > I used the word "message" in a misleading way. I did not mean > "message" as erlang message sent to another process. simply alleged to > "message" (a "tweet" if you prefer) passed from person A to person B > intended for person C, from function to function in this case, an arg > passed to fun z() like this: > > a()-> > S = #state{}, > b(S). > > b(S)-> > c(S). > > ... > > z(S)-> > Z = S#state.some_var. > > an arg S passed to another fun X, which fun X may or may not use, > simply pass it to the next fun and so on. > > this state passing clutters the code and makes refactoring difficult. > I prefer to only pass the args the fun actually needs. If some other > fun down the line needs the state, let it get it directly. Many years ago I had occasion to compare a Lisp program using global variables and its Prolog analogue passing around a tuple. Oddly enough, the Prolog version was faster. The central problem with the process dictionary is that if you are * writing a library module, you cannot use it, because you do not know what keys your caller might be using * using a library module, you cannoy use it, because you do not know what keys your library might be using. Dolphin Smalltalk, possibly the most visually attractive Smalltalk I've ever seen, has some way to attach properties to any object. I never bothered to learn how to use it because I didn't fancy never knowing what might already be in use. One way to reduce but not eliminate exposure to this problem is to use module_name.variable_name keys. Speaking of Smalltalk, I have my own Smalltalk to C compiler. At the moment, something like x times: y raisedToInteger: z turns into t3 = k_times_raisedToInteger(l1/*x*/, l2/*y*/, l3/*z*/); but I'm thinking about changing it to t3 = k_times_raisedToInteger(CONTEXT, l1/*x*/, l2/*y*/, l3/*z*/); with the context parameter being a pointer to per-thread data, just passed around and around, because I am fed up with the portability and efficiency problems caused by using per-thread data in C. That is, I want to move AWAY from the model you like. This will make no difference whatever to my Smalltalk code, except (I hope) to make it faster and to make a bit more of it thread-safe. And that's the way to go in Erlang. If you want a feature like this, write a preprocessor. Then the source code *won't* be cluttered and refactoring *won't* be a problem and you don't have to wait until the community sorts out an effective design. From ok@REDACTED Wed Feb 18 01:32:32 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 18 Feb 2015 13:32:32 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: <11219577.5VlZ0ycJe9@changa> References: <3557038.bkb3CVCkxg@changa> <11219577.5VlZ0ycJe9@changa> Message-ID: <6DBF1BED-523A-4525-9874-89F5200A3848@cs.otago.ac.nz> On 18/02/2015, at 6:37 am, zxq9 wrote: > If you find yourself writing an excessive number of functions that simply > receive arguments to pass them through it may be a good idea to ask yourself > why your programs are winding up this way before you start hunting for ways to > dance around the design decisions that underly the system. Sometimes it isn't > easy to avoid passing, say, a gen_server's #state (or something similar) along > here and there, but usually refactoring for functional generalization also > winds up yielding code that does a lot less argument passthrough. +1. Well put. From ok@REDACTED Wed Feb 18 01:41:59 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 18 Feb 2015 13:41:59 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <3557038.bkb3CVCkxg@changa> <11219577.5VlZ0ycJe9@changa> Message-ID: <74B6C8FE-CF30-4BCC-B645-661B9CC5A646@cs.otago.ac.nz> On 18/02/2015, at 9:38 am, Imants Cekusins wrote: > how about those process scope variables though? :-P > more reliable than process dict. No, they aren't. They are essentially the same thing. The process dictionary approach has one overwhelming advantage. It has been part of Erlang for a long time. It's there; it works; you can use it NOW, and other Erlang programmers will know what it means. It has problems, but it can do the job, and the problems are a helpful reminder that maybe the job should not be done. > same principles as function scope > variables: immutable, gc'ed when the process finishes. > > would noone else use them? Let's see: no 'process scope variables' in Concurrent ML; no 'process scope variables' as such in Haskell; nothing but painful experiences with 'thread local' variables in C; ... Nope. Not going to use them. I would prefer to thread a state record/map through 100 functions. Give me a 'process' form that IS a syntactic scope, as in Ada, where variables declared inside a 'task' are *naturally* process-local and genuinely syntactically scope, and I have no trouble with them. One major issue for me is that "process scope" (gosh it grates to use the word "scope" for something that is not a scope) is not good enough. Given such a thing, the next thing is to want to introduce or revise a variable binding within the body of some function and have the binding go away/revert when the function is complete. That is trivial when you are passing a state record/map around. With single-level "process scope" variables, one starts demanding more machinery. From e@REDACTED Wed Feb 18 01:42:08 2015 From: e@REDACTED (e@REDACTED) Date: Wed, 18 Feb 2015 01:42:08 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <54E3B535.70503@bestmx.net> Message-ID: <54E3DFE0.8070308@bestmx.net> On 02/17/2015 11:06 PM, Imants Cekusins wrote: >> "process dictionary" and it is a profound source of bugs and pain > > does it cause problems because it is mutable? it causes problems because it is against purity From ok@REDACTED Wed Feb 18 01:47:24 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 18 Feb 2015 13:47:24 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <130270E0-6C99-4677-92D0-9DBE6BA756E7@cs.otago.ac.nz> Message-ID: On 18/02/2015, at 1:06 pm, Imants Cekusins wrote: > Richard, this was a very simplified example. Yeah. Brian Marick has some lovely stickers. He let me have two. The one on my door says "To be less wrong than yesterday." The other one says "An example would be handy about now." Something I often demand in this mailing list is REAL examples. If someone puts up a 200-line module somewhere, and posts a message saying "what's a good way to rewrite that?", nobody is annoyed by high-volume messages, and we can really get our teeth into the problem and suggest refactorings, possibly even of a kind that had not occurred to the original poster. Me, I'm very fond of code generation, so when someone says "code like this is hard to write by hand", my response is sometimes "so don't write it by hand then." > by "static" I meant immutable. yes, "static" can mean various things. > in this case it is a misnomer. "Immutable" is not one of the things "static" can mean. From imantc@REDACTED Wed Feb 18 02:05:39 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 02:05:39 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <130270E0-6C99-4677-92D0-9DBE6BA756E7@cs.otago.ac.nz> Message-ID: > It has problems, but it can do the job, and the problems are a helpful reminder that maybe the job should not be done. Could you go into more detail about the problems with the process dictionary, please? -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Wed Feb 18 02:38:05 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 02:38:05 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <130270E0-6C99-4677-92D0-9DBE6BA756E7@cs.otago.ac.nz> Message-ID: > Immutable" is not one of the things "static" can mean. Richard, I think I need to use state in some form. I may have used a good few wrong words but I the main reasons should be obvious. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zxq9@REDACTED Wed Feb 18 02:50:15 2015 From: zxq9@REDACTED (zxq9) Date: Wed, 18 Feb 2015 10:50:15 +0900 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E3DFE0.8070308@bestmx.net> References: <54E3DFE0.8070308@bestmx.net> Message-ID: <10401244.oVxlpREO85@changa> On 2015?2?18? ??? 01:42:08 e@REDACTED wrote: > On 02/17/2015 11:06 PM, Imants Cekusins wrote: > >> "process dictionary" and it is a profound source of bugs and pain > > > > does it cause problems because it is mutable? > > it causes problems because it is against purity No. Erlang is anything but a "pure" language or a "pure" system or even based on "pure" principles. Erlang has cherry picked from the orchard that grows bewteen the lofty ivory launch tower of the language astronauts and the filthy, nutrient rich bog where expedient-but-short-lived code rots. From e@REDACTED Wed Feb 18 02:57:15 2015 From: e@REDACTED (e@REDACTED) Date: Wed, 18 Feb 2015 02:57:15 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <10401244.oVxlpREO85@changa> References: <54E3DFE0.8070308@bestmx.net> <10401244.oVxlpREO85@changa> Message-ID: <54E3F17B.2040603@bestmx.net> On 02/18/2015 02:50 AM, zxq9 wrote: > On 2015?2?18? ??? 01:42:08 e@REDACTED wrote: >> On 02/17/2015 11:06 PM, Imants Cekusins wrote: >>>> "process dictionary" and it is a profound source of bugs and pain >>> >>> does it cause problems because it is mutable? >> >> it causes problems because it is against purity > > No. > > Erlang is anything but a "pure" language did i ever stated the opposite? to whom do you address your "No"? From imantc@REDACTED Wed Feb 18 03:06:39 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 03:06:39 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E3F17B.2040603@bestmx.net> References: <54E3DFE0.8070308@bestmx.net> <10401244.oVxlpREO85@changa> <54E3F17B.2040603@bestmx.net> Message-ID: Let's move on from "who wrote what" to "how to do it", please? Suggestions are very welcome. Especially technical caveats with process dict (if any) -------------- next part -------------- An HTML attachment was scrubbed... URL: From e@REDACTED Wed Feb 18 03:25:06 2015 From: e@REDACTED (e@REDACTED) Date: Wed, 18 Feb 2015 03:25:06 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <54E3DFE0.8070308@bestmx.net> <10401244.oVxlpREO85@changa> <54E3F17B.2040603@bestmx.net> Message-ID: <54E3F802.60707@bestmx.net> On 02/18/2015 03:06 AM, Imants Cekusins wrote: > Let's move on from "who wrote what" to "how to do it", please? > > Suggestions are very welcome. Especially technical caveats with process > dict (if any) i gave you my suggestions already. i have nothing to add. From ok@REDACTED Wed Feb 18 03:29:13 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 18 Feb 2015 15:29:13 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <130270E0-6C99-4677-92D0-9DBE6BA756E7@cs.otago.ac.nz> Message-ID: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> On 18/02/2015, at 2:05 pm, Imants Cekusins wrote: > > It has problems, but it can do the job, and the problems are a > helpful reminder that maybe the job should not be done. > > Could you go into more detail about the problems with the process dictionary, please? I already did. (1) It's mutable. You can sort of fix this by using wrapper functions: safe_put(Key, Val) -> undefined = get(Key), put(Key, Val). (2) Keys are global, not per-module. If you call code from a module that you have not read, you cannot tell which keys it might use for its own purposes. You can sort of fix this by using module_name.variable_name keys. As it happens, the Erlang libraries DO use the process dictionary, most notably for holding the random generator state. The number of keys used is in the low hundreds, and *most* of them are safely hidden inside other processes, but I don't KNOW which are and which are not. If your process-scope variables are per-module, then a lot of the problem goes away. (In particular, when I last looked, nothing in the Erlang libraries used M.V style keys.) And then you have the problem of not being able to refer to a variable in another module when you want to, which guess what, *prevents* some useful refactorings. (3) There is as far as I know no tool support to help with (2) or even with tracking key use within a single module. Since ANY term may be used as a key, things like receive Key -> receive Val -> put(Key, Val) end end are possible, meaning that as far as I can tell, it isn't even theoretically possible to be complete and correct. Some kind of approximate (ideally conservative) tool would be nice. This can be worked around by writing a trivial preprocessor. This one is in AWK to keep the message short. /^-[ \t]*module[(]/ { module = $0 sub(/^-[ \t]*module[(][ \t]*/, "", module) sub(/[^a-zA-Z0-9_.].*$/, "", module) print next } /[ \t](get|put)[(][.][a-z]/ { key = $0 sub(/^.*[ \t](get|put)[(][.]/, "", key) sub(/[^a-zA-Z0-9_.].*$/, "", key) tally[key]++ match($0, /[(][.]/) print substr($0, 1, RSTART) module substr($0, RSTART+1) next } { print } END { for (key in tally) printf "%3d %s\n", tally[key], key >"/dev/stderr" } will turn -module(fee). -export([fie/0, foh/0, fum/0]). fie() -> put(.key, 1). foh() -> N = get(.key), put(.key, N+1). fum() -> get(.key). into -module(fee). -export([fie/0, foh/0, fum/0]). fie() -> put(fee.key, 1). foh() -> N = get(fee.key), put(fee.key, N+1). fum() -> get(fee.key). and write 4 key to stderr, so I can see what keys are used this way. THIS IS JUST A TOY EXAMPLE. I DO NOT USE IT IN PRACTICE. (4) There is the memory leak problem. If you put something in the process dictionary, it will stay there until it is explicitly removed. There is no automatic garbage collection of keys from the process dictionary. While you have not presented a detailed specification of process scope variables, it looks like they would be even *worse* in this regard, because at least there is erase(dead_key). What would you use for oddball variables? From imantc@REDACTED Wed Feb 18 03:55:58 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 03:55:58 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> References: <130270E0-6C99-4677-92D0-9DBE6BA756E7@cs.otago.ac.nz> <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> Message-ID: Thank you very much indeed! A lot of useful detail. Key clash is not a problem. I will only use a handful of predefined keys for known shared values. Will still pass variables to functions. The module &fun which set the value can be stored in the dict for debugging. The key does not need to tie to the module. Will not use the dict for odd variables. Is process dict not gc'ed even after the process completes? The dict can be erased but what if this does not happen? Is it possible to accidentally read from / write to system key? Thank you very much indeed. -------------- next part -------------- An HTML attachment was scrubbed... URL: From zxq9@REDACTED Wed Feb 18 04:05:57 2015 From: zxq9@REDACTED (zxq9) Date: Wed, 18 Feb 2015 12:05:57 +0900 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: <7662590.02IB3hHcgi@changa> On 2015?2?18? ??? 02:05:39 Imants Cekusins wrote: > > It has problems, but it can do the job, and the problems are a > > helpful reminder that maybe the job should not be done. > > Could you go into more detail about the problems with the process > dictionary, please? At this point all the major sides of the discussion surrounding the wisdom of global variables have been recounted. If you're really only interested in constants, then you have four main choices (in the order I prefer): 1. A function wrapper around the value: some_value() -> 7. The function call involved will be optimized away by the compiler, but this shouldn't concern you anyway unless you discover that this is a bottleneck (and you can never know until you actually profile it in use...). 2. An element in a #state{} record: S = #s{some_value = 7}. % From here on grab a hold of S#s.some_value whenever you need it. 3. Hey, Marco, a Macro! -define(SOME_VALUE, 7). This sucks for various reasons and achieves the same effect as #1 in any case (after compilation *literally* the same effect, but now with far less flexibility in terms of refactoring your code later if you use ?SOME_VALUE in several places). 4. Process dictionary. Ugh... Just too easy to abuse (so easy to start using it as a mutable global hack), and seriously, for a value that isn't going to change doing this is sort of ridiculous: some_fun(X, Y) -> Computrons = compute(get(Z), X, Y). More favorable is: some_fun(X, Y) -> Computrons = compute(z(), X, Y). While the latter is easier to refactor than using a macro, is still generally less smooth than just working with the OTP assumptions you're already operating within anyway: some_fun(X, Y, S#s{Z = z}) -> Computrons = compute(Z, X, Y). The record version has the advantage of making perfect sense as both a very clear part of process initialization (its pretty standard to see people pack everything up front right there instead of tuck magic values away somewhere else later in the code), and prevents any need for hunting around when things crash -- because every relevant value was in the function arguments, so you can re-test the code *exactly* as it was run yourself and quickly narrow down what caused the crash. On the other hand -- think carefully about this question: When will you ever desire to insert a constant into a module that is not a library? (I discussed the "global variable" thing a bit on SO, using different examples and wording things differently here: http://stackoverflow.com/questions/25770042/variable-in-erlang/25775401#25775401) If you need a dynamic value then the only practical way to go is using a state tuple/record. Technically you could go with the process dictionary for this, but as an experiment try writing a program that does everything through the process dictionary instead of a state record, then the same one that does everything through a state record -- and compare the readability, discoverability and post-crash trace meaningfullness of the two versions. There is a reason you've never seen any documentation that does everything through the process dictionary; writing a non-trivial gen_server that works that way is a great way to discover why. You replied to ROK something to the effect that "I need state, for obvious reasons". Well, everyone does. And this is what we do: we use a tuple that represents the state of the process. If its a lot of state then a record is definitely called for, but its not impossible even without this (its just a syntactic convenience anyway). (Incidentally, using a tuple is a good way to discover that there is a healthy balance somewhere between data structure depth and the ideal of collection flatness...) When using a record a refactoring doesn't have to involve changing anything in the middle of a chain of passthrough functions. It actually makes this so easy that many people commit to long chains of passthrough when they really shouldn't. But I digress... In any case, I think the best thing for you to do now is sally forth and write useful code. Lots of it. Use the process dictionary. Watch the world spin faster! Don't use the process dictionary! Watch it spin... about the same! Use an ETS table for every bit you can think you might want to pack in there. Who cares, so long as your code works, right? And then discover which approaches are easier or harder to debug in actual practice. Several of us have given our opinions and the reasoning behind them. I don't have a long litany of anecdotal evidence for "wow, I'm SOOOO glad I didn't use the process dictionary here!" because I learned that lesson a long time ago in Scheme, C and Python, and so have just steered clear of the process dictionary in Erlang so far because it hasn't been an *obvious* correct answer to any problem I've faced thus far. Beyond this point the discussion will necessarily devolve into either religion or astronautics, so best to avoid that and at least produce something useful and have fun on your way to developing your own insights into the issue. -Craig From zxq9@REDACTED Wed Feb 18 04:11:00 2015 From: zxq9@REDACTED (zxq9) Date: Wed, 18 Feb 2015 12:11 +0900 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> Message-ID: <2355659.CI61d1bmZG@changa> On 2015?2?18? ??? 03:55:58 Imants Cekusins wrote: > for known shared values. Wait, what? Shared values? Please tell me you just misspoke. In any case, the general imprecision of much of the discussion leads me to believe you just need to spend some more time writing Erlang programs to familiarize yourself with the reasoning behind the common solutions to most situations. This thread is beginning to smell a lot like it blossomed from an XY Problem Seed. From imantc@REDACTED Wed Feb 18 05:27:44 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 05:27:44 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <2355659.CI61d1bmZG@changa> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> Message-ID: Ok I'll go with the process dictionary. If this does not work, will think again. Thank you very much everyone. From Alexey.Saltanov@REDACTED Wed Feb 18 08:03:18 2015 From: Alexey.Saltanov@REDACTED (Saltanov, Alexey) Date: Wed, 18 Feb 2015 07:03:18 +0000 Subject: [erlang-questions] r16b02 odbc-2.10.17 crash on bind NULL output value. Message-ID: <0589296B5BCDDA4A8F5CEB3F8739A815011442ED87@SRV-EXCHMBX2.billing.ru> I try to execute some code: {ok, Conn} = odbc:connect("user/pass@REDACTED", [{scrollable_cursors, off}, {auto_commit, on}, {binary_strings, on}]). odbc:param_query (Conn, "begin ? := null; end;", [{{sql_varchar, 8000}, out, [<<"">>]}]). And odbcserver crashes... ODBC: received unexpected info: {tcp_closed,#Port<0.4260>} GNU gdb (GDB) 7.7 Copyright (C) 2014 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-unknown-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: . Find the GDB manual and other documentation resources online at: . For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /home/alex/src/odbc/priv/bin/odbcserver...done. [New LWP 17872] [New LWP 17873] warning: Corrupted shared library list: 0x7f6c7f1f5000 != 0x0 [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". Core was generated by `/home/alex/src/odbc/priv/bin/odbcserver'. Program terminated with signal SIGSEGV, Segmentation fault. #0 0x0000003c40a0df16 in _dl_fixup () from /lib64/ld-linux-x86-64.so.2 (gdb) bt #0 0x0000003c40a0df16 in _dl_fixup () from /lib64/ld-linux-x86-64.so.2 #1 0x0000003c40a14695 in _dl_runtime_resolve () from /lib64/ld-linux-x86-64.so.2 #2 0x00007f6c7d5034f0 in ?? () #3 0x0000000000000000 in ?? () Why odbcserver crashes on binding NULL value into varchar output parameter? -------------- next part -------------- An HTML attachment was scrubbed... URL: From kenji@REDACTED Wed Feb 18 13:49:09 2015 From: kenji@REDACTED (Kenji Rikitake) Date: Wed, 18 Feb 2015 21:49:09 +0900 Subject: [erlang-questions] FreeBSD dtrace-enabled builds In-Reply-To: <1423658200.3778291.226102697.6175A110@webmail.messagingengine.com> References: <1423658200.3778291.226102697.6175A110@webmail.messagingengine.com> Message-ID: <20150218124909.GA2392@k2r.org> I've never seen the "WARNING: number of probes fixed..." message in my environment (a kerl-built 17.4.1 with dtrace). I haven't recently tested the dtrace build on Port lang/erlang. See https://github.com/jj1bdx/dot-kerlrc/blob/master/dot-kerlrc-freebsd for the .kerlrc config. I suggest you to file a problem report at https://bugs.freebsd.org/bugzilla/ Kenji Rikitake ++> Dave Cottlehuber [2015-02-11 13:36:40 +0100]: > On Sat, 31 Jan 2015, at 10:02 AM, Dave Cottlehuber wrote: > > Hi, > > > > On FreeBSD 10.1R amd64, after building a modified lang/erlang port, the > > following alarming warning is displayed. This is the same in the newer > > lang/erlang-runtime17 flavour as well BTW. > > > > WARNING: number of probes fixed does not match the number of defined > > probes (1001 != 1088, respectively) > > WARNING: some probes might not fire or your program might crash > > Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:8:8] [async-threads:64] > > [hipe] [kernel-poll:true] [dtrace] > > > > Eshell V6.3 ?(abort with ^G) > > 1> > > > > No doubt this is in reference the forthcoming zombie apocalypse? > > > > How serious is this ? does anybody have practical experience to relate? > > > > Any idea on what the problem might be or what I might need to do to fix > > it? > > > > Assuming this is resolved, what is the practical impact of using a > > dtrace-enabled build in production? Is there likely to be a significant > > performance hit, or is this even foolish from a stability perspective? > > Handwavey answers are entirely appropriate here. > > > > A+, Dave > > ? sent from my Couch > > Gently bumping this dtrace thread... any takers? > > Thanks! > Dave > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From zandra@REDACTED Wed Feb 18 15:23:58 2015 From: zandra@REDACTED (Zandra Hird) Date: Wed, 18 Feb 2015 15:23:58 +0100 Subject: [erlang-questions] {error,closed} vs. {error,econnreset} In-Reply-To: References: Message-ID: <54E4A07E.5010307@erlang.org> Hi, yes this sounds confusing. We looked into it a little bit but couldn't find the reason for it right away. Have you tried tracing the resv0 in prim_inet? It might give you some more information about why this happens. We can look into it some more too when we get the time, and if you don't find out more before that :) / Zandra On 2015-02-10 14:39, Bekes, Andras G wrote: > > Hi All, > > Looks like I have a problem with the erroneous result of > gen_tcp:recv/2, as it returns {error,closed} instead of my expectation > of {error,econnreset}. > > I can reproduce my problem by: > > 1, starting a server application and forcing it into a busy state when > it is listening but not accepting connections > > 2,starting 1000 clients (in Erlang) that connect to the server, > filling the TCP listen backlog of the server. > > When the backlog is filled and after some time (~2 minutes), the > Erlang connections return {error,closed}. > > This is what I do in Erlang: > > fun()->{ok,Socket}= TCPCONNECT(HOST,PORT), > ok=gen_tcp:send(Socket,<<"SOMEDATA??>>), > io:format("~p:~p\n",[self(),gen_tcp:recv(Socket,100)]) > > end. > > spawn this 1000 times. > > 3, a native client of the service however tells me that the connection > was reset by peer. > > According to strace, it executes a recvfrom which returns ECONNRESET: > > recvfrom(...) = -1 ECONNRESET (Connection reset by peer) > > I also straced the Erlang beam process and it indeed gets an > ECONNRESET result for the recvfrom call, but the Erlang return value > is {error,closed}. > > Unfortunately it looks like I really need to separate these two results. > > I also tried gen_tcp in active mode, but no difference, the result is > {error,closed} instead of {error,econnreset}. > > Can someone explain why the econnreset error is masked? Is there any > way I can separate the two kinds of events? > > Thanks, > > Andras G. Bekes > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From zandra@REDACTED Wed Feb 18 15:57:56 2015 From: zandra@REDACTED (Zandra Hird) Date: Wed, 18 Feb 2015 15:57:56 +0100 Subject: [erlang-questions] erlang http tcp_closed problem In-Reply-To: References: Message-ID: <54E4A874.8000401@erlang.org> Hi, It might have to do with some internal buffer limitation (see doc http://www.erlang.org/doc/man/inet.html), so you can try to set packet_size to big enough to handle the large cookie header and see if it helps. / Zandra On 2015-02-12 10:36, Przemys?aw Wycisk wrote: > The reason of that behaviour was option packet_size on socket. Default > set of this option ({packet_size, 0}) should mean no size (line size > in http) limit shouldn't it?, but packets were dropped because of > large cookie header. > I consider it as a bug, and also i think that if line size limit in > http socket occurs i should get http_error instead of tcp_closed, it's > quite confusing. > > On Sun, Feb 8, 2015 at 7:25 PM, Przemys?aw Wycisk > > wrote: > > I've got problem with using erlang active http socket. > > I receive msgs like that: > > ok = inet:setopts(Sock,[{active, true}]), > receive > {http, Sock, {http_request, HttpMethod, {abs_path, Path}, > _HttpVersion}} -> > Headers = getHeaders(Sock), > %more code > > and then headers like that: > > getHeaders(Sock, Headers) -> > receive > {http, Sock, {http_header, _Num, 'Content-Length', _, Value}} -> > NewHeaders = Headers#'headers'{contentLength = Value}, > getHeaders(Sock, NewHeaders); > {http, Sock, {http_header, _Num, 'Host', _, Value}} -> > NewHeaders = Headers#'headers'{host = Value}, > getHeaders(Sock, NewHeaders); > {http, Sock, {http_header, _Num, 'User-Agent', _, Value}} -> > NewHeaders = Headers#'headers'{userAgent = Value}, > getHeaders(Sock, NewHeaders); > %more headers here > % > > {http, Sock, {http_error, Error}} -> > ?LOG_INFO("protocol", "http returned error with reason:~p~n", > [Error]), > exit(normal); > {http, Sock, http_eoh} -> > Headers; > {tcp_closed, Sock} -> % > ?LOG_INFO("connection", "Socket ~w closed by client", [Sock]), > exit(normal); > _Else -> > getHeaders(Sock, Headers) > end. > > > Normally it works fine, packets and headers are received from > browser and everyone is happy, but there is a case, when a browser > sends a request, and then i get "tcp_closed" in place where mark> is placed, in the middle of receiving headers. > > This behaviour is strange for me, because it never happens in > incognito mode. That could mean that bowsers cache is involved in > the problem, but how? > > Anyone had the same problem? Anyone could help? I would be grateful. > > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From sverker.eriksson@REDACTED Wed Feb 18 16:49:07 2015 From: sverker.eriksson@REDACTED (Sverker Eriksson) Date: Wed, 18 Feb 2015 16:49:07 +0100 Subject: [erlang-questions] erlang http tcp_closed problem In-Reply-To: <54E4A874.8000401@erlang.org> References: <54E4A874.8000401@erlang.org> Message-ID: <54E4B473.9030201@erix.ericsson.se> I would guess that you get a {tcp_error, Socket, emsgsize} message, which you ignore in your _Else clause. About packets being rejected even though {packet_size,0} is default. I would consider this a documentation bug maybe. I don't think we want to change the default behavior to be vulnerable agains DoS attacks with insane long http lines in need of buffer space. /Sverker, Erlang/OTP On 02/18/2015 03:57 PM, Zandra Hird wrote: > Hi, > > It might have to do with some internal buffer limitation (see doc > http://www.erlang.org/doc/man/inet.html), so you can try to set > packet_size to big enough to handle the large cookie header and see if > it helps. > > / Zandra > > > On 2015-02-12 10:36, Przemys?aw Wycisk wrote: >> The reason of that behaviour was option packet_size on socket. >> Default set of this option ({packet_size, 0}) should mean no size >> (line size in http) limit shouldn't it?, but packets were dropped >> because of large cookie header. >> I consider it as a bug, and also i think that if line size limit in >> http socket occurs i should get http_error instead of tcp_closed, >> it's quite confusing. >> >> On Sun, Feb 8, 2015 at 7:25 PM, Przemys?aw Wycisk >> > wrote: >> >> I've got problem with using erlang active http socket. >> >> I receive msgs like that: >> >> ok = inet:setopts(Sock,[{active, true}]), >> receive >> {http, Sock, {http_request, HttpMethod, {abs_path, Path}, >> _HttpVersion}} -> >> Headers = getHeaders(Sock), >> %more code >> >> and then headers like that: >> >> getHeaders(Sock, Headers) -> >> receive >> {http, Sock, {http_header, _Num, 'Content-Length', _, Value}} -> >> NewHeaders = Headers#'headers'{contentLength = Value}, >> getHeaders(Sock, NewHeaders); >> {http, Sock, {http_header, _Num, 'Host', _, Value}} -> >> NewHeaders = Headers#'headers'{host = Value}, >> getHeaders(Sock, NewHeaders); >> {http, Sock, {http_header, _Num, 'User-Agent', _, Value}} -> >> NewHeaders = Headers#'headers'{userAgent = Value}, >> getHeaders(Sock, NewHeaders); >> %more headers here >> % >> >> {http, Sock, {http_error, Error}} -> >> ?LOG_INFO("protocol", "http returned error with reason:~p~n", >> [Error]), >> exit(normal); >> {http, Sock, http_eoh} -> >> Headers; >> {tcp_closed, Sock} -> % >> ?LOG_INFO("connection", "Socket ~w closed by client", [Sock]), >> exit(normal); >> _Else -> >> getHeaders(Sock, Headers) >> end. >> >> >> Normally it works fine, packets and headers are received from >> browser and everyone is happy, but there is a case, when a browser >> sends a request, and then i get "tcp_closed" in place where > mark> is placed, in the middle of receiving headers. >> >> This behaviour is strange for me, because it never happens in >> incognito mode. That could mean that bowsers cache is involved in >> the problem, but how? >> >> Anyone had the same problem? Anyone could help? I would be grateful. >> >> >> >> >> _______________________________________________ >> 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 imantc@REDACTED Wed Feb 18 22:40:23 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 22:40:23 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> Message-ID: here is an option in case someone runs into this same problem: if the process is run within a gen_server / gen_fsm, any method can call the gen_ to obtain or update the state: gen_server:call(self(), Request) gen_fsm:sync_send_all_state_event(self(), Event) then there is no need to lug the state around. not sure if this was mentioned. From imantc@REDACTED Wed Feb 18 23:36:16 2015 From: imantc@REDACTED (Imants Cekusins) Date: Wed, 18 Feb 2015 23:36:16 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> Message-ID: oops.. sync call times out when own gen_ is called apologies for misleading. it won't work like this. From zxq9@REDACTED Thu Feb 19 00:31:24 2015 From: zxq9@REDACTED (zxq9) Date: Thu, 19 Feb 2015 08:31:24 +0900 Subject: [erlang-questions] Process scope variable In-Reply-To: References: Message-ID: <7054065.U2Zvr4M8LN@changa> On 2015?2?18? ??? 22:40:23 Imants Cekusins wrote: > here is an option in case someone runs into this same problem: Can you define the problem you have? This entire discussion has been about an artifact of a particular implementation of a solution you are hell-bent on writing. But you have never identified the problem. That is why I mentioned earlier that this is beginning to smell like an XY Problem: http://mywiki.wooledge.org/XyProblem From imantc@REDACTED Thu Feb 19 01:11:28 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 01:11:28 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <7054065.U2Zvr4M8LN@changa> References: <7054065.U2Zvr4M8LN@changa> Message-ID: > Can you define the problem you have? I consider various ways to use process state. From n.oxyde@REDACTED Thu Feb 19 01:25:37 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Thu, 19 Feb 2015 01:25:37 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <7054065.U2Zvr4M8LN@changa> Message-ID: <1E499A78-FDC2-4C2E-B346-B604598D84BB@gmail.com> Le 19 f?vr. 2015 ? 01:11, Imants Cekusins a ?crit : >> Can you define the problem you have? > > I consider various ways to use process state. Could you show us the code where you want to use such a thing? From imantc@REDACTED Thu Feb 19 01:35:08 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 01:35:08 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <1E499A78-FDC2-4C2E-B346-B604598D84BB@gmail.com> References: <7054065.U2Zvr4M8LN@changa> <1E499A78-FDC2-4C2E-B346-B604598D84BB@gmail.com> Message-ID: > Could you show us the code where you want to use such a thing? well the code is very simple in structure. Gen_fsm modules calling multiple methods in succession. Those methods call other methods in turn. There is no problem to get the code working. It works after every round of refactoring. I like the way it is structured, can follow and debug it. It makes sense to me. This is important. The reason for this quest for state is quite simple, I do not hesitate to refactor continuously. So, to speed up refactoring, I am looking to simplify function signatures (args & return types) as much as I can. Also quite frankly I am used to OOP and noticed that for me it is easier and faster to write code when state is in the picture. From fritchie@REDACTED Thu Feb 19 06:03:04 2015 From: fritchie@REDACTED (Scott Lystig Fritchie) Date: Wed, 18 Feb 2015 23:03:04 -0600 Subject: [erlang-questions] FreeBSD dtrace-enabled builds In-Reply-To: Message of "Wed, 18 Feb 2015 21:49:09 +0900." <20150218124909.GA2392@k2r.org> Message-ID: <39941.1424322184@snookles.snookles.com> Kenji Rikitake wrote: kr> I've never seen the "WARNING: number of probes fixed..." message in kr> my environment (a kerl-built 17.4.1 with dtrace). Nor have I, sorry. Sorry, Dave, I'm at a loss. My home box is FreeBSD 9 and has no complaints. I spun up a FreeBSD 10.1 amd64 machine this morning and compiled via: pkg install gmake pkg install perl5 kldload dtraceall ./configure --prefix=/usr/local/erlang/17.4 --enable-vm-probes \ --with-dynamic-trace=dtrace |& tee RUNLOG.c make |& tee RUNLOG.0 ... and then running './bin/erl' didn't yield any errors. [vagrant@REDACTED /usr/local/src/erlang/otp_src_17.4]$ ./bin/erl Erlang/OTP 17 [erts-6.3] [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false] [dtrace] Eshell V6.3 (abort with ^G) 1> l(dyntrace). {module,dyntrace} 2> dyntrace:available(). true -Scott From dch@REDACTED Thu Feb 19 12:54:40 2015 From: dch@REDACTED (Dave Cottlehuber) Date: Thu, 19 Feb 2015 12:54:40 +0100 Subject: [erlang-questions] FreeBSD dtrace-enabled builds In-Reply-To: <39941.1424322184@snookles.snookles.com> References: <39941.1424322184@snookles.snookles.com> Message-ID: <1424346880.754968.229621673.16544C7F@webmail.messagingengine.com> Thanks everybody for their help. The secret incantations are: # ensure dtrace kernel module is available sudo -s # right now kldload dtraceall # and for evermore echo '"dtraceall_load="YES"' >> /boot/loader.conf # make/gmake changes cat >> /etc/make.conf < References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> Message-ID: ok, found the solution: store complete state in a separate linked gs. when an fsm A starts, it start_links a gs B whose sole responsibility is store & update A's state content. A does not really store anything apart from B's pid. maybe a ref, too - to filter out unintended calls. this "state" gs B can be called from any process (A or any spawned one) to store or update A's state. so the only piece of state we need to pass around is the gs B Pid. "simple'z" :) remember to stop the "state" gs when the parent fsm terminates. how about that? From essen@REDACTED Thu Feb 19 13:56:19 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Thu, 19 Feb 2015 13:56:19 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> Message-ID: <54E5DD73.5070804@ninenines.eu> On 02/19/2015 01:51 PM, Imants Cekusins wrote: > how about that? So much time spent for removing one State variable from a few function calls... You're overthinking this. -- Lo?c Hoguin http://ninenines.eu From imantc@REDACTED Thu Feb 19 14:04:28 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 14:04:28 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E5DD73.5070804@ninenines.eu> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: > So much time spent for removing one State variable from a few function calls. much more time will be saved when refactoring from now on. imagine: most funs will now have signature: -spec a(pid()) -> ok. and most function bodies will look like: check(Pid), update(Pid), return(Pid). it will be a breeze now. From essen@REDACTED Thu Feb 19 14:07:07 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Thu, 19 Feb 2015 14:07:07 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: <54E5DFFB.7000609@ninenines.eu> On 02/19/2015 02:04 PM, Imants Cekusins wrote: >> So much time spent for removing one State variable from a few function calls. > > much more time will be saved when refactoring from now on. > > imagine: > most funs will now have signature: > > -spec a(pid()) -> ok. > > and most function bodies will look like: > check(Pid), > update(Pid), > return(Pid). > > it will be a breeze now. So basically instead of State you have Pid? I'm not sure I understand the improvement. -- Lo?c Hoguin http://ninenines.eu From steve@REDACTED Thu Feb 19 14:07:54 2015 From: steve@REDACTED (Steve Strong) Date: Thu, 19 Feb 2015 14:07:54 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: Rather you than me :) Personally, when in a functional language, I quite like reading a function and thinking ?cool, a function called ?fred? that operates on data A, B, and C?. I shudder when I recall my 20+ years of OO and thinking ?ok, a method called ?fred?. Wonder what it does?" -- Steve Strong Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Thursday, 19 February 2015 at 14:04, Imants Cekusins wrote: > > So much time spent for removing one State variable from a few function calls. > > > much more time will be saved when refactoring from now on. > > imagine: > most funs will now have signature: > > -spec a(pid()) -> ok. > > and most function bodies will look like: > check(Pid), > update(Pid), > return(Pid). > > it will be a breeze now. > _______________________________________________ > 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 imantc@REDACTED Thu Feb 19 14:12:29 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 14:12:29 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E5DFFB.7000609@ninenines.eu> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> Message-ID: > instead of State you have Pid a fun can return just what it did, without {Return, State} so no more S1 = a(State), S2 = b(S1) simply a(Pid) b(Pid) also, given simplified standard signatures, I do not need to navigate the full spagetti path to check & recheck if I call a fun correctly. refactoring will take me at least 50% less time. From essen@REDACTED Thu Feb 19 14:16:26 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Thu, 19 Feb 2015 14:16:26 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> Message-ID: <54E5E22A.6090202@ninenines.eu> On 02/19/2015 02:12 PM, Imants Cekusins wrote: >> instead of State you have Pid > > a fun can return just what it did, without > {Return, State} > > so no more > S1 = a(State), > S2 = b(S1) > > simply > a(Pid) > b(Pid) You say "simply" but it is anything but simple. People reading your code will just end up scratching their heads. You will also spend more time writing tests and debugging. Are you sure this is what you want? -- Lo?c Hoguin http://ninenines.eu From imantc@REDACTED Thu Feb 19 14:16:50 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 14:16:50 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: > "ok, a method called 'fred'. Wonder what it does?" well let's just say if I understand program flow, this is not a problem. If I do not understand it, long explicit signatures are not of much help. my problem was that until now my mind was too cluttered with function signatures. now when I look at a function body, I can focus on what happens within this function. I will worry about other functions in turn - when I look at them. basically, navigating the code will happen much less often. the mind can take a rest. From n.oxyde@REDACTED Thu Feb 19 14:18:41 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Thu, 19 Feb 2015 14:18:41 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> Message-ID: <67F7438E-0E23-4482-AB07-8F452D8C9754@gmail.com> Le 19 f?vr. 2015 ? 14:12, Imants Cekusins a ?crit : >> instead of State you have Pid > > a fun can return just what it did, without > {Return, State} > > so no more > S1 = a(State), > S2 = b(S1) > > simply > a(Pid) > b(Pid) > > > also, given simplified standard signatures, I do not need to navigate > the full spagetti path to check & recheck if I call a fun correctly. > > refactoring will take me at least 50% less time. If you don't want to post the actual code where you think you need this, I don't see why that conversation should continue. We kept telling you to post the code to see what the hell you are talking about but you refuse to do so. I would hate refactoring such code where I have no idea what will be used where. I also don't see why you would reply to me in French. From imantc@REDACTED Thu Feb 19 14:18:51 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 14:18:51 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E5E22A.6090202@ninenines.eu> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <54E5E22A.6090202@ninenines.eu> Message-ID: Loic I'd rather spend time debugging than navigating spagetti path and trying to remember what I was looking for. I work with a variety of languages and so far using state was not a problem for me. I am used to using state. From n.oxyde@REDACTED Thu Feb 19 14:20:55 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Thu, 19 Feb 2015 14:20:55 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: <68BD195A-3200-4657-86BD-75A7776133AF@gmail.com> Le 19 f?vr. 2015 ? 14:16, Imants Cekusins a ?crit : > well let's just say if I understand program flow, this is not a > problem. If I do not understand it, long explicit signatures are not > of much help. My own experience of fixing ~40 bugs in the Erlang compiler disagrees. From imantc@REDACTED Thu Feb 19 14:24:47 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 14:24:47 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <67F7438E-0E23-4482-AB07-8F452D8C9754@gmail.com> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <67F7438E-0E23-4482-AB07-8F452D8C9754@gmail.com> Message-ID: Anthony, this is about general coding syntax / approach, not any particular programming task. Apologies for using language you did not expect. > My own experience of fixing ~40 bugs in the Erlang compiler disagrees. I do not impose or prescribe such programming style. Simply mention it as an alternative. It may not be applicable in every situation or for every programmer. programmers think differently. the large variety of languages prove this. From n.oxyde@REDACTED Thu Feb 19 14:27:18 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Thu, 19 Feb 2015 14:27:18 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <67F7438E-0E23-4482-AB07-8F452D8C9754@gmail.com> Message-ID: <840E2B40-9D95-4CB9-AF09-3F711E024C09@gmail.com> Le 19 f?vr. 2015 ? 14:24, Imants Cekusins a ?crit : > Anthony, this is about general coding syntax / approach, not any > particular programming task. Richard O'Keefe already made a good case against debates about "general coding syntax / approach" which are not accompanied with actual code in this very thread, I won't repeat what he already said. From vladdu55@REDACTED Thu Feb 19 14:38:23 2015 From: vladdu55@REDACTED (Vlad Dumitrescu) Date: Thu, 19 Feb 2015 14:38:23 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: Hi Imants, Are you sure that you will still understand the program flow in 3 or 6 or 12 months from now, especially if you will be working with something else in between? Are you sure that the "state server" will only be written to from only one process? You might be throwing away exactly what Erlang is good at and will be in no better position than if you had implemented the code in Java or C++. At least, you might want to use an ETS table instead, where you can get some kind of protection if implemented correctly. In my experience, it is usually a poor solution to try to use a different paradigm than the one the language/environment offer natively (I tried it in many ways). It can be done, but it requires more work than one thinks from the beginning, it might become less understandable than one had planned and in the end it might be faster/simpler to go with a different language/environment, if the choice of paradigm is not negotiable. regards, Vlad On Thu, Feb 19, 2015 at 2:16 PM, Imants Cekusins wrote: > > "ok, a method called 'fred'. Wonder what it does?" > > well let's just say if I understand program flow, this is not a > problem. If I do not understand it, long explicit signatures are not > of much help. > > my problem was that until now my mind was too cluttered with function > signatures. > > now when I look at a function body, I can focus on what happens within > this function. I will worry about other functions in turn - when I > look at them. > > basically, navigating the code will happen much less often. the mind > can take a rest. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Thu Feb 19 14:49:32 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 14:49:32 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: Hi Vlad, > Are you sure that you will still understand the program flow in 3 or 6 or 12 months from now, especially if you will be working with something else in between? well it is not always simple. The frequent refactoring I mentioned aims to produce the code that makes sense. This will allow me to speed up continuous refactoring. I also document code much more extensively that is often expected. > Are you sure that the "state server" will only be written to from only one process? I will use Pid & ref. Will make sure they are passed only within A process. I do not spawn much. > throwing away exactly what Erlang is good at Erlang is good and convenient in many respects. If Java were better suited, I would use Java of course. In this case Erlang is more suitable and convenient. For me, this approach speeds up code delivery and code readability. I do not anticipate bug increase. From mononcqc@REDACTED Thu Feb 19 15:17:53 2015 From: mononcqc@REDACTED (Fred Hebert) Date: Thu, 19 Feb 2015 09:17:53 -0500 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> Message-ID: <20150219141746.GC4955@ferdair.local> On 02/19, Imants Cekusins wrote: > > instead of State you have Pid > > a fun can return just what it did, without > {Return, State} > > so no more > S1 = a(State), > S2 = b(S1) > > simply > a(Pid) > b(Pid) > > also, given simplified standard signatures, I do not need to navigate > the full spagetti path to check & recheck if I call a fun correctly. > > refactoring will take me at least 50% less time. You do realize that what you did is introduce the equivalent of a global mutable variable into your program, right? You no longer need to navigate the full spaghetti to check if the function is called correctly, true (which is easy to do *automatically* when you have things such as Dialyzer, by the way). Instead you now have to navigate the full spaghetti whenever something goes wrong because one of the calls -- any of them -- goes wrong. And now you need to explicitly trace or weave out the state in the other process whenever it behaves funny, checking the full spaghetti with a lot more pain than you would have otherwise. Will refactoring take 50% less time because you won't need to properly understand what goes on before you do it, or because you dislike sequences of variables needing to be renumbered? If a function call fails and your process ends up killed, are the mechanism to figure it out well thought out? You realize you implicitly changed the use of a direct stacktrace into asynchronous error handling via monitors and links, right? This is doable, but has a cost, too! You'll be splitting the error source from its handling. This is desirable in isolated processes doing isolated tasks, but is it desirable in this case? Have you, for example, considered calling `b(a(State))' ? Regards, Fred. From imantc@REDACTED Thu Feb 19 15:34:14 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 15:34:14 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <20150219141746.GC4955@ferdair.local> References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> Message-ID: Hi Fred, thank your for taking time to read this. well the "state" gs calls would be quite fail-proof: get_state, set_state. The gs would only hold the state and make it accessible from anywhere. the rest of the program flow stays pretty much intact, no? to operate on the state variables I would still need to get state, assign it to a local variable in a function, then pass it to some function to work on this var. I do not aim to completely eliminate args. e.g. there would still be funs like parse(Bin) -> #parsed{}. it would be obvious from parse/1 signature that it does not change the state - another benefit. From t@REDACTED Thu Feb 19 15:36:36 2015 From: t@REDACTED (Tristan Sloughter) Date: Thu, 19 Feb 2015 08:36:36 -0600 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> Message-ID: <1424356596.827822.229705053.7C87E404@webmail.messagingengine.com> Why even pass the pid! -module(terrible). -export([a/0]). -export([process_state/1]). a() -> start_process_state(), proc_put(a, 10), b(). b() -> {ok, Value} = proc_get(a), Value + 1. start_process_state() -> Pid = self(), proc_lib:spawn_link(?MODULE, process_state, [Pid]), receive ready -> ok end. proc_get(Key) -> Atom = list_to_atom(pid_to_list(self())), Atom ! {get, Key}, receive Result -> Result end. proc_put(Key, Value) -> Atom = list_to_atom(pid_to_list(self())), Atom ! {put, Key, Value}, receive Result -> Result end. process_state(Pid) -> register(list_to_atom(pid_to_list(Pid)), self()), Pid ! ready, process_state(Pid, dict:new()). process_state(Pid, State) -> receive {get, Key} -> Pid ! dict:find(Key, State), process_state(Pid, State); {put, Key, Value} -> case dict:is_key(Key, State) of true -> Pid ! error, process_state(Pid, State); false -> Pid ! ok, process_state(Pid, dict:store(Key, Value, State)) end end. From imantc@REDACTED Thu Feb 19 15:39:10 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 15:39:10 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> Message-ID: > Will refactoring take 50% less time because you won't need to properly understand what goes on before you do it, or because you dislike sequences of variables needing to be renumbered? because I can now move and swap function calls without constantly checking and amending the signatures all over the place - which for me is a massive overhead. From garry@REDACTED Thu Feb 19 15:43:57 2015 From: garry@REDACTED (Garry Hodgson) Date: Thu, 19 Feb 2015 09:43:57 -0500 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: <54E5F6AD.9050009@research.att.com> On 2/19/15 8:49 AM, Imants Cekusins wrote: > Erlang is good and convenient in many respects. If Java were better > suited, I would use Java of course. In this case Erlang is more > suitable and convenient. For me, this approach speeds up code delivery > and code readability. I do not anticipate bug increase. erlang is not java, and FP is not OO. you seem to be going through a lot of effort to use erlang in a way that violates fundamental notions of FP. if that works for you, great, but i doubt you're going to convert anyone here. From imantc@REDACTED Thu Feb 19 15:44:29 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 15:44:29 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <1424356596.827822.229705053.7C87E404@webmail.messagingengine.com> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <1424356596.827822.229705053.7C87E404@webmail.messagingengine.com> Message-ID: > Why even pass the pid! > -module(terrible). instead of the gs? well gs is more solid, with terminate/2 and timeout where we could catch errors. btw here: b() -> {ok, Value} = proc_get(a), Value + 1. - the "state" gs would not act on state - only get & set From mononcqc@REDACTED Thu Feb 19 15:46:32 2015 From: mononcqc@REDACTED (Fred Hebert) Date: Thu, 19 Feb 2015 09:46:32 -0500 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> Message-ID: <20150219144631.GD4955@ferdair.local> On 02/19, Imants Cekusins wrote: > > it would be obvious from parse/1 signature that it does not change the > state - another benefit. It would be possible to do the same with: get(Key::atom(), #state{}) -> Value::term(). Because the state is a record that isn't returned, you know this bit to not be modified. Similarly with: set(Key::atom(), Val::term(), #state{}) -> #state{}. You know from the signature you *should* track state if you want its updates. This lets you know, for example, that `get` could be used in a map, but `set` would require a fold. But it would be impossible to know that from: get(Key::atom(), pid()) -> Value::term(). Granted, the pid is not returned anymore than #state{}, but we know pids to behave a bit like pointers to mutable state. This changes a few things, doesn't it? What about this: set(Key::atom(), Val::term(), pid()) -> ok. Oh, woops. Yeah then we can't know anything except that we're pretty much guaranteed side-effects now. The reason why parse/1's signature is clear is because you expect it to encompass everything it does. That's specifically the reason your state-modifying signatures will be far less useful than they could be. Because you want some global mutable state. The only difference between your approach and the process dictionary is that you added the overhead of message passing to it. From imantc@REDACTED Thu Feb 19 15:47:16 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 15:47:16 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E5F6AD.9050009@research.att.com> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> Message-ID: > i doubt you're going to convert anyone here. oh no, this is not my intention. This is just a thought. Share my experience so to say. From gguthrie@REDACTED Thu Feb 19 15:47:34 2015 From: gguthrie@REDACTED (Gordon Guthrie) Date: Thu, 19 Feb 2015 14:47:34 +0000 Subject: [erlang-questions] Process scope variable In-Reply-To: <54E5F6AD.9050009@research.att.com> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> Message-ID: <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> I agree Imants You are delaying the inevitable - if you wish to use a functional programming ecosystem like Erlang/OTP you will need to learn to write code in a functional style and refactor it. It is perfectly possible to write good FP code that is easy to refactor - the problem is that you don?t know how. And it sounds like you have inherited an OO-flavoured Erlang codebase... Focus on learning that - rather than mating the OO goat to the FP camel - you will have a better time of it? Gordon > Le 19 f?vr. 2015 ? 14:43, Garry Hodgson a ?crit : > > On 2/19/15 8:49 AM, Imants Cekusins wrote: >> Erlang is good and convenient in many respects. If Java were better suited, I would use Java of course. In this case Erlang is more suitable and convenient. For me, this approach speeds up code delivery and code readability. I do not anticipate bug increase. > erlang is not java, and FP is not OO. > you seem to be going through a lot of effort > to use erlang in a way that violates fundamental > notions of FP. if that works for you, great, but > i doubt you're going to convert anyone here. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From lamchith@REDACTED Thu Feb 19 15:50:13 2015 From: lamchith@REDACTED (Lamchith M C) Date: Thu, 19 Feb 2015 20:20:13 +0530 Subject: [erlang-questions] Calling openssl from erlang Message-ID: I was trying to use openssl functions from erlang, like PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, int flags). I thought of using a NIF (Native Implemented Function) to call a this openssl c function from erlang. The samples given at site have return types like int , which is available in both c and erlang. How openssl type PKCS7* can be mapped to an erlang type , which is the return type for openssl function PKCS7_encrypt,so that , I can call openssl functions like this from erlang program. Is there any sample program I can look into*.* -- Regards, Lamchith -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Thu Feb 19 15:53:49 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 15:53:49 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: this approach would hopefully run programs very similarly to how conventionally written programs would run. I mean, in terms of program output, memory consumption, speed. I tried writing in the traditional way. It took me too long. In waterfall style, this could work for me. But I do not work in waterfall style. Very, very agile - slow agile, so far. From jesper.louis.andersen@REDACTED Thu Feb 19 16:06:07 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Thu, 19 Feb 2015 16:06:07 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: On Thu, Feb 19, 2015 at 3:53 PM, Imants Cekusins wrote: > I tried writing in the traditional way. It took me too long. In > waterfall style, this could work for me. But I do not work in > waterfall style. Very, very agile - slow agile, so far. > The balance between ease of writing and subtle errors in the program is harsh and rough. You can write the program faster, but also risk introducing more bugs. What do you choose? In general, if you can split computation from effect, then do so. Refactoring is easier in such a program and it only commits to a choice as late as possible, when it commits to the effects. Threading state around and keeping track of small updates all the time doesn't split the computation and effect and as such it is pretty bad functional style. It is also hard to refactor. You need pure functions to ease quick development and testing without having to worry about state updates and such. Some planning helps: keep the parameter order consistent in your code. Inverting the data flow is often useful. FP is data-flow oriented programming, so you need to spend time on it. Imperative code is control-flow oriented, so you can't adapt the flow from a typical imperative style. Experience helps too. Some times, threading state is unavoidable and it really is the best way to describe the function. Other times, another flow is better. Another axis: implicit state all have the same problem, be it Haskell State monads, process dictionaries, 'a ref cells in ML, global variables, or an object field in Java. They hide information for the reader of the code and relies on them figuring out implicit variable relationship on their own. You can perhaps write the code faster, but the next reader is hampered by the implicit passing of state. Which introduces bugs. If you could pick between fast and wrong agile and slow and correct agile, what do you choose? -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Thu Feb 19 16:06:41 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 16:06:41 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: another thought: let's take JavaScript. Originally it was designed to be be used in certain ways. And what people are doing with Javascript now? Various frameworks. Run it on server, create classes, call plain vanilla funs, MVVM, templates. It looks like Javascript, but is not vanilla Js anymore.. So we add a class flavour to otp. Big deal. It's still Erlang OTP. From jesper.louis.andersen@REDACTED Thu Feb 19 16:09:37 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Thu, 19 Feb 2015 16:09:37 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: On Thu, Feb 19, 2015 at 4:06 PM, Imants Cekusins wrote: > So we add a class flavour to otp. Big deal. It's still Erlang OTP. We had this as an experiment for years. It did not work out in the end, but it was a fun experiment, nonetheless :) Perhaps it will reappear in another form when we do know how to address it fully and marry it to Erlang/OTP in a better way. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Thu Feb 19 16:16:18 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 16:16:18 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: > If you could pick between fast and wrong agile and slow and correct agile, what do you choose? the goal is fast and correct agile. I may run into unexpected technical problems. Time will tell. Remember: when the app design is largely over, it is still possible to take away the "state" gs, beef up fun signatures and pass the state around - test & deploy the program refactored to correct way. I do not mind long signatures when the design is not going to change. Work in progress will however be faster with the "state" gs. From sverker.eriksson@REDACTED Thu Feb 19 16:46:12 2015 From: sverker.eriksson@REDACTED (Sverker Eriksson) Date: Thu, 19 Feb 2015 16:46:12 +0100 Subject: [erlang-questions] Calling openssl from erlang In-Reply-To: References: Message-ID: <54E60544.8070407@erix.ericsson.se> This is what application crypto does; acts as a interface toward libcrypto in OpenSSL. I can't see that crypto calls PKCS7_encrypt however. To return pointers from NIF to erlang you probably want to use the resource concept in the NIF interface. /Sverker, Erlang/OTP On 02/19/2015 03:50 PM, Lamchith M C wrote: > I was trying to use openssl functions from erlang, like > PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, int > flags). > > I thought of using a NIF (Native Implemented Function) to call a this > openssl c function from erlang. The samples given at site have return types > like int , which is available in both c and erlang. How openssl type PKCS7* > can be mapped to an erlang type , which is the return type for openssl > function PKCS7_encrypt,so that , I can call openssl functions like > this from erlang program. Is there any sample program I can look into*.* > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From radek@REDACTED Thu Feb 19 18:41:10 2015 From: radek@REDACTED (Rad Gruchalski) Date: Thu, 19 Feb 2015 18:41:10 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: On Thursday, 19 February 2015 at 16:16, Imants Cekusins wrote: > > If you could pick between fast and wrong agile and slow and correct agile, what do you choose? > > > the goal is fast and correct agile. I started learning Erlang about 10 months ago. Frankly, I like not having state and classes. To me it sounds like you?re reinventing Scala. Try Scala, it?s not terrible, it?s way better than Java, you can do functional or imperative, the code may look very nice if you know Scala well. You have to try hard to stay functional so it sounds like a perfect fit for you. It seems you don?t get the functional programming yet. You just need more experience. I would suggest the following: leave what you?re doing now on the side, read ?Designing for scalability with Erlang/OTP? and write the examples yourself. This is how I started. It was an eye opener. > > I may run into unexpected technical problems. Time will tell. > > Remember: when the app design is largely over, it is still possible to > take away the "state" gs, beef up fun signatures and pass the state > around - test & deploy the program refactored to correct way. I do not > mind long signatures when the design is not going to change. > > Work in progress will however be faster with the "state" gs. > _______________________________________________ > 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 vincent.dephily@REDACTED Thu Feb 19 18:43:26 2015 From: vincent.dephily@REDACTED (Vincent de Phily) Date: Thu, 19 Feb 2015 18:43:26 +0100 Subject: [erlang-questions] Fwd: Figuring out proper ssl certificate settings with 17.3 In-Reply-To: References: <4306941.X6676PlrAe@moltowork> Message-ID: <2200058.cD7JN7KKEC@moltowork> On Thursday 22 January 2015 21:45:08 Ingela Andin wrote: > Hi! Hi, thanks for the detailed explanations. Sorry for my late reply : urgent tasks, holidays and the need to digest the info all contributed to the delay. > There was a bug in R16 that if the client sends only its peer-cert and the > server happens to own the intermediate CA cert that signed the client cert > it concludes that the intermediate CA cert is the trusted cert and > everything works. That behavior made sense to me, I wouldn't have labeled it as a bug :p If I know/trust a CA that signed one of the certs that the peer sends me in its certificate_list, then I can trust the whole list that the peer sent. > But according to the TLS protocol the client must send > the whole chain only the self signed ROOT may be excluded from the chain. > However pkix-X509 certificate path validation says it should be possible > to put the trust in an intermediate cert, I'm not going to pretend that I know better than the RFC writers, but taken together (particularly the RFC quotes from your changeset[1]) it seems that rfc5246's "only the top/root cert may be ommited" rule should be understood as "only the certs that are expected to be known by the peer may be ommited". > and that is why we have the > partial_chain to allow path validation on only part of the chain, so that > means the server that accepts a partial chain could know of the > intermediate cert but not own the ROOT, as it has decided to trust the > intermediate CA. I don't understand why certs specified in {cacerts,[der_encoded()]} are not trusted. What is the usecase of providing untrusted certs in cacerts ? I've also been unable to make use of the partial_chain option the way I expected it to work (to ensure that what I put in cacert is trusted) : Clientside: {certfile, Account1Device1Cert}, {cacerts, [ServerCA]} {partial_chain, fun(_) -> {trusted_ca,ServerCA} end} Serverside: {certfile, Account1ServerCert}, {cacerts, [ClientCA]} {partial_chain, fun(_) -> {trusted_ca,ClientCA} end} It seems to be because the fun only accepts to accept a CA as the base of a partial chain if that CA has been sent by the peer. But in my case the CA has not been sent by the peer : it's expected to be in the local list of trusted certs. > So a TLS client that can not build its whole chain is incorrectly > configured. Depends on what you call "whole". The question is wether one can follow its chain up to a trusted certificate, not wether one can follow its chain up to a self-signed certificate. On the wider internet, the recommendation that a peer sends a cert chain with all CAs except the last is a good one, because you never know which CA is in the other peer's store. When in doubt, send as much info as possible. But sending a CA that is already known/trusted by the peer is a waste of bandwidth, and there are plenty of usecases where you can expect the peer to know the necessary CA. That's why "send the whole chain excluding the root" is only recomended, not mandatory (unless there's a security issue I missed ?). > E.i. the partial chain function lets you shorten the chain by accepting an > intermediate cert sent to you by the peer as trusted. Ok, that's what I eventually understood. But why is it limited to intermediate certs *sent by the peer* ? I've got the intermediate cert right there in my local cacerts list. It has signed the leaf cert sent by the client. > If you want to handle > incorrect clients by building the chain to the client certificate on the > server side , if possible, you need to do that in the verify_fun when it > fails and then call public_key:pkix_path_validation again with the chain > that you built. I didn't try this yet, but I verified that > {partial_chain, fun(CAs) -> {trusted_ca,hd(CAs)} end} "solves" my issue but is basically a verify_none. It seems there's some functionality overlap between partial_chain and verify_fun, but I'm not 100% sure when to use which. I'd like OTP to do the "peer-sent cert chain is signed by one of the localy- trusted CAs" step for me. I realize that I could do it myself using the public_key module, but I find it very surprising that my usecase would be so unusual that it isn't supported out of the box. A peer that sends the smallest chain that can be verified by the other peer isn't "incorrect". > As the self-signed root cert may be left out of the chain client software > will guess that if the signer of a cert is not found it must be the > self-signed root, however if > the client is not correctly configured this could be a wrong guess. I'm not sure I understand this. Why guess ? Either you have the CA that signed a cert (wether that's a root CA or an intermediate one) or you don't. > > I guess some confusion comes from the fact that the cacerts option is used > > for > > two different things (authenticating the cert received by the peer, and > > sending intermediate CAs to the peer to help it authenticate me). Maybe > > the > > option could be split in two ? > > This is documented and you will find the same behaviour in openSSL. It may be, but that doesn't make it a clear API :p Openssl isn't renowned for having a good API. It's nice that OTP can use 'cacerts' to build the chain that signs 'cert', but sometimes the resulting chain is overkill. And maybe I don't want to trust a peer whose cert is signed by the same CA as my own cert ? What about allowing 'cert' to be [der_encoded()] instead of der_encoded() ? If a list is provided, use that as the chain. If a single cert is provided, try to build a chain using cacerts. > Client side: > > *{cacertfile, path()}*The path to a file containing PEM encoded CA > certificates. The CA certificates are used during server authentication and > when building the client certificate chain. > > > Sever side: > > *{cacertfile, path()}* > The path to a file containing PEM encoded CA certificates. The CA > certificates are used to build the server certificate chain, and for client > authentication. Also the CAs are used in the list of acceptable client CAs > passed to the client when a certificate is requested. May be omitted if > there is no need to verify the client and if there are not any intermediate > CAs for the server certificate. The wordings are different, but they seem compatible. One is just wordyer than the other. Also, if cacertfile really is different between client and server, why isn't cacerts ? I know that, thanks to the web, most authentications are only one-way so that it's tempting to provide more information in one of the cases. But really, authentication should be symetrical (wether it's sending your certs to the peer or listing the CAs you trust). > Hope that helps. I does, thanks. Things are clearer in my head, but I'm still not convinced by the new OTP behavior ;) [1]:https://github.com/otphub/public_key/commit/314358c71d58eeb2556924b43dccb3c087db2407 -- Vincent de Phily From imantc@REDACTED Thu Feb 19 18:54:22 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 18:54:22 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: > Try Scala, Hi Rad, Erlang is perfect. This little trick is only a small extension for productivity purpose. Thank you for the book suggestion. I will pick it up at some stage. From radek@REDACTED Thu Feb 19 19:07:45 2015 From: radek@REDACTED (Rad Gruchalski) Date: Thu, 19 Feb 2015 19:07:45 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: On Thursday, 19 February 2015 at 18:54, Imants Cekusins wrote: > > Try Scala, > > > Hi Rad, > > Erlang is perfect. This little trick is only a small extension for > productivity purpose. > > We agree to disagree. The simplest way of achieving what you are trying to do is to have a gen_server with an underlaying ets table. You can then call for your ?state?. You keep OTP principles and have state. There are use cases where this is indeed a tempting shortcut. From an experience though, shortcuts usually lead to poor architectural decisions. And that?s not only in Erlang, that?s any technology. > Thank you for the book suggestion. I will pick it up at some stage. I?d read it first. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryankbrown@REDACTED Thu Feb 19 20:02:58 2015 From: ryankbrown@REDACTED (Ryan Brown) Date: Thu, 19 Feb 2015 12:02:58 -0700 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 In-Reply-To: References: Message-ID: Thank you Felix. I did get that to work standalone. It appears that there is something in the pad_binary method that I have not been able to track-down. In a crude attempt to trace the issue down, I added a bunch of io:formats and ran in the shell. pad_binary_128(Data) when bit_size(Data) > 128 -> io:format("Line ~p~n", [89]), {Kept, _Lost} = split_binary(Data, size(Data) - 1), io:format("Line ~p~n", [94]), pad_binary_128(Kept); pad_binary_128(Data) when bit_size(Data) < 128 -> io:format("Line ~p~n", [97]), pad_binary_128(<>); pad_binary_128(Data) -> io:format("Line ~p~n", [100]), Data. This is the output I get: Line 97 ** exception error: bad argument in function omac1:pad_binary_128/1 (src/omac1.erl, line 97) in call from omac1:cmac_aes_cbc_128/6 (src/omac1.erl, line 78) So, it almost seems like there may be a difference in the way that bit_size/1 is handled in R1603. However, I do not see anything that stands-out to me in the docs. http://erldocs.com/R15B01/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 http://erldocs.com/R16B03/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 Thanks in advance. Best, Ryan On Tue, Feb 17, 2015 at 5:21 PM, Felix Gallo wrote: > I made your same changes to the module, and also added the following > function to the module: > > test() -> > Key = <<1:128>>, > Data = <<1:128>>, > generate_tag_aes_cbc_128(Key, Data). > > and when run in a shell: > > Eshell V6.1 (abort with ^G) > 1> c(omac1),l(omac1),omac1:test(). > <<173,219,62,66,7,255,149,96,196,74,41,116,238,229,211,35>> > > this appears to work (at least, it doesn't crash with badarg. I don't > know whether the data is correct). Are you sure your aes key is 128, 192, > or 256 bits long? It's possible the crypto module is throwing badarg when > it detects an improper length key. > > On Tue, Feb 17, 2015 at 3:27 PM, Ryan Brown wrote: > >> Thank you Felix. It looks like the aes_cbc_128_encrypt method is gone so >> I changed all to use crypto:block_encrypt(aes_cbc128, Key, IV, >> ToBeEncrypted) >> >> But alas, I'm still seeing the same error. >> >> On Tue, Feb 17, 2015 at 3:10 PM, Felix Gallo >> wrote: >> >>> I'm not super familiar with the crypto library, but it looks like its >>> function signatures changed significantly between 15B01 and 16B03. In >>> particular, it appears that some of the functions you are calling are no >>> longer in the library, and have been replaced with equivalents. >>> >>> I suggest opening >>> >>> http://erldocs.com/R15B01/crypto/crypto.html >>> >>> and >>> >>> http://erldocs.com/R16B03/crypto/crypto.html >>> >>> and seeing if you can figure out where the changes occurred. I suspect >>> those are the cause of your badargs. >>> >>> F. >>> >>> On Tue, Feb 17, 2015 at 1:55 PM, Ryan Brown >>> wrote: >>> >>>> Hello all, >>>> >>>> I am in the process of upgrading a legacy application from R15B01 to >>>> R16B03 in order to get SHA 384 support. However, I am getting an error >>>> creating my CMAC from the library located here: >>>> >>>> https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl >>>> >>>> For the life of me I cannot find the root cause. I am just receiving a >>>> badarg error pointing to line 74. >>>> >>>> Any guidance would be greatly appreciated. >>>> >>>> Thank you. >>>> >>>> >>>> >>>> _______________________________________________ >>>> erlang-questions mailing list >>>> erlang-questions@REDACTED >>>> http://erlang.org/mailman/listinfo/erlang-questions >>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From felixgallo@REDACTED Thu Feb 19 21:33:05 2015 From: felixgallo@REDACTED (Felix Gallo) Date: Thu, 19 Feb 2015 12:33:05 -0800 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 In-Reply-To: References: Message-ID: A constructive note: it's hard for readers (e.g. me) to reason about what's happening without a full, minimal failing test case, including the data you're passing in. Just the act of creating a minimal failing test case is also a great debugging step that often illuminates/solves the problem (along the lines of 'rubber duck debugging' ( http://en.wikipedia.org/wiki/Rubber_duck_debugging)). For example, maybe you're passing in the wrong kind of data; that is very common and is frequently exposed when you type it in a second time and look at it. For the purposes of this discussion I created a test() function: test() -> X = <<1:128>>, Y = <<1:53>>, Z = <<1:1>>, pad_binary_128(X), pad_binary_128(Y), pad_binary_128(Z). and then I run it like so: Eshell V6.1 (abort with ^G) 1> c(a),l(a),a:test(). Line 100 Line 97 ** exception error: bad argument in function a:pad_binary_128/1 (a.erl, line 12) in call from a:test/0 (a.erl, line 22) and see your error when I am trying to use a 53 bit bitstring. In this particular scenario that matches the clause: pad_binary_128(Data) when bit_size(Data) < 128 -> io:format("Line ~p~n", [97]), pad_binary_128(<>); this appears to me be an excessively clever attempt to right-pad the binary with zeroes. In particular, the original author thought <> would construct a binary with one zero to the right, and then recursion would continue until the string was 128 bits long. As a debug step, let's break out the construction attempt from the function call: New = <>; pad_binary_128(New); now we get the error at the constructor. How exciting! So we turn to the documentation ( http://www.erlang.org/doc/programming_examples/bit_syntax.html) and see that you will get badarg errors when you attempt to construct a binary that has an unaligned byte boundary -- e.g., anything not divisible by 8. In this case, Data/binary could be attempting to convert an unaligned bitstring into a binary, which can't be done. In order to fix the problem in a short term way, you could change that to <> and it would run fine. But it also recurses for every single bit of padding, which is a little, ah, corkbrained. Better would be to refactor this code a little so it's a bit more sensible. I am by no means an erlang grandmaster but here's how I personally would do it. The specs pass dialyzer and there's a brief test suite that hits some of the high notes. https://github.com/Cloven/bitpad128/blob/master/bit_example.erl F. On Thu, Feb 19, 2015 at 11:02 AM, Ryan Brown wrote: > Thank you Felix. I did get that to work standalone. It appears that there > is something in the pad_binary method that I have not been able to > track-down. > > In a crude attempt to trace the issue down, I added a bunch of io:formats > and ran in the shell. > > pad_binary_128(Data) when bit_size(Data) > 128 -> > io:format("Line ~p~n", [89]), > {Kept, _Lost} = split_binary(Data, size(Data) - 1), > io:format("Line ~p~n", [94]), > pad_binary_128(Kept); > pad_binary_128(Data) when bit_size(Data) < 128 -> > io:format("Line ~p~n", [97]), > pad_binary_128(<>); > pad_binary_128(Data) -> > io:format("Line ~p~n", [100]), > Data. > > This is the output I get: > > Line 97 > ** exception error: bad argument > in function omac1:pad_binary_128/1 (src/omac1.erl, line 97) > in call from omac1:cmac_aes_cbc_128/6 (src/omac1.erl, line 78) > > So, it almost seems like there may be a difference in the way that > bit_size/1 is handled in R1603. However, I do not see anything that > stands-out to me in the docs. > > http://erldocs.com/R15B01/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 > http://erldocs.com/R16B03/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 > > Thanks in advance. > > Best, > > Ryan > > On Tue, Feb 17, 2015 at 5:21 PM, Felix Gallo wrote: > >> I made your same changes to the module, and also added the following >> function to the module: >> >> test() -> >> Key = <<1:128>>, >> Data = <<1:128>>, >> generate_tag_aes_cbc_128(Key, Data). >> >> and when run in a shell: >> >> Eshell V6.1 (abort with ^G) >> 1> c(omac1),l(omac1),omac1:test(). >> <<173,219,62,66,7,255,149,96,196,74,41,116,238,229,211,35>> >> >> this appears to work (at least, it doesn't crash with badarg. I don't >> know whether the data is correct). Are you sure your aes key is 128, 192, >> or 256 bits long? It's possible the crypto module is throwing badarg when >> it detects an improper length key. >> >> On Tue, Feb 17, 2015 at 3:27 PM, Ryan Brown wrote: >> >>> Thank you Felix. It looks like the aes_cbc_128_encrypt method is gone so >>> I changed all to use crypto:block_encrypt(aes_cbc128, Key, IV, >>> ToBeEncrypted) >>> >>> But alas, I'm still seeing the same error. >>> >>> On Tue, Feb 17, 2015 at 3:10 PM, Felix Gallo >>> wrote: >>> >>>> I'm not super familiar with the crypto library, but it looks like its >>>> function signatures changed significantly between 15B01 and 16B03. In >>>> particular, it appears that some of the functions you are calling are no >>>> longer in the library, and have been replaced with equivalents. >>>> >>>> I suggest opening >>>> >>>> http://erldocs.com/R15B01/crypto/crypto.html >>>> >>>> and >>>> >>>> http://erldocs.com/R16B03/crypto/crypto.html >>>> >>>> and seeing if you can figure out where the changes occurred. I suspect >>>> those are the cause of your badargs. >>>> >>>> F. >>>> >>>> On Tue, Feb 17, 2015 at 1:55 PM, Ryan Brown >>>> wrote: >>>> >>>>> Hello all, >>>>> >>>>> I am in the process of upgrading a legacy application from R15B01 to >>>>> R16B03 in order to get SHA 384 support. However, I am getting an error >>>>> creating my CMAC from the library located here: >>>>> >>>>> https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl >>>>> >>>>> For the life of me I cannot find the root cause. I am just receiving a >>>>> badarg error pointing to line 74. >>>>> >>>>> Any guidance would be greatly appreciated. >>>>> >>>>> Thank you. >>>>> >>>>> >>>>> >>>>> _______________________________________________ >>>>> erlang-questions mailing list >>>>> erlang-questions@REDACTED >>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>> >>>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryankbrown@REDACTED Thu Feb 19 22:11:20 2015 From: ryankbrown@REDACTED (Ryan Brown) Date: Thu, 19 Feb 2015 14:11:20 -0700 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 In-Reply-To: References: Message-ID: Thank you for the excellent clarification Felix. This code was written five years ago and we are just trying to update the version of Erlang it's running on. Everything seems to run fine on R15B (has been in production w/o issue for five years). So, while I was able to refactor the code to work, I suppose I am still scratching my head as to why this would have changed between R15 and R16. I've read the release readme and don't see anything obvious. Best regards, Ryan On Thu, Feb 19, 2015 at 1:33 PM, Felix Gallo wrote: > A constructive note: it's hard for readers (e.g. me) to reason about > what's happening without a full, minimal failing test case, including the > data you're passing in. Just the act of creating a minimal failing test > case is also a great debugging step that often illuminates/solves the > problem (along the lines of 'rubber duck debugging' ( > http://en.wikipedia.org/wiki/Rubber_duck_debugging)). For example, maybe > you're passing in the wrong kind of data; that is very common and is > frequently exposed when you type it in a second time and look at it. > > For the purposes of this discussion I created a test() function: > > test() -> > X = <<1:128>>, > Y = <<1:53>>, > Z = <<1:1>>, > pad_binary_128(X), > pad_binary_128(Y), > pad_binary_128(Z). > > and then I run it like so: > > Eshell V6.1 (abort with ^G) > 1> c(a),l(a),a:test(). > Line 100 > Line 97 > ** exception error: bad argument > in function a:pad_binary_128/1 (a.erl, line 12) > in call from a:test/0 (a.erl, line 22) > > and see your error when I am trying to use a 53 bit bitstring. > > In this particular scenario that matches the clause: > > pad_binary_128(Data) when bit_size(Data) < 128 -> > io:format("Line ~p~n", [97]), > pad_binary_128(<>); > > this appears to me be an excessively clever attempt to right-pad the > binary with zeroes. In particular, the original author thought > <> would construct a binary with one zero to the right, > and then recursion would continue until the string was 128 bits long. > > As a debug step, let's break out the construction attempt from the > function call: > > New = <>; > pad_binary_128(New); > > now we get the error at the constructor. How exciting! > > So we turn to the documentation ( > http://www.erlang.org/doc/programming_examples/bit_syntax.html) and see > that you will get badarg errors when you attempt to construct a binary that > has an unaligned byte boundary -- e.g., anything not divisible by 8. In > this case, Data/binary could be attempting to convert an unaligned > bitstring into a binary, which can't be done. > > In order to fix the problem in a short term way, you could change that to > <> and it would run fine. But it also recurses for > every single bit of padding, which is a little, ah, corkbrained. > > Better would be to refactor this code a little so it's a bit more > sensible. I am by no means an erlang grandmaster but here's how I > personally would do it. The specs pass dialyzer and there's a brief test > suite that hits some of the high notes. > > https://github.com/Cloven/bitpad128/blob/master/bit_example.erl > > F. > > On Thu, Feb 19, 2015 at 11:02 AM, Ryan Brown wrote: > >> Thank you Felix. I did get that to work standalone. It appears that there >> is something in the pad_binary method that I have not been able to >> track-down. >> >> In a crude attempt to trace the issue down, I added a bunch of io:formats >> and ran in the shell. >> >> pad_binary_128(Data) when bit_size(Data) > 128 -> >> io:format("Line ~p~n", [89]), >> {Kept, _Lost} = split_binary(Data, size(Data) - 1), >> io:format("Line ~p~n", [94]), >> pad_binary_128(Kept); >> pad_binary_128(Data) when bit_size(Data) < 128 -> >> io:format("Line ~p~n", [97]), >> pad_binary_128(<>); >> pad_binary_128(Data) -> >> io:format("Line ~p~n", [100]), >> Data. >> >> This is the output I get: >> >> Line 97 >> ** exception error: bad argument >> in function omac1:pad_binary_128/1 (src/omac1.erl, line 97) >> in call from omac1:cmac_aes_cbc_128/6 (src/omac1.erl, line 78) >> >> So, it almost seems like there may be a difference in the way that >> bit_size/1 is handled in R1603. However, I do not see anything that >> stands-out to me in the docs. >> >> >> http://erldocs.com/R15B01/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 >> >> http://erldocs.com/R16B03/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 >> >> Thanks in advance. >> >> Best, >> >> Ryan >> >> On Tue, Feb 17, 2015 at 5:21 PM, Felix Gallo >> wrote: >> >>> I made your same changes to the module, and also added the following >>> function to the module: >>> >>> test() -> >>> Key = <<1:128>>, >>> Data = <<1:128>>, >>> generate_tag_aes_cbc_128(Key, Data). >>> >>> and when run in a shell: >>> >>> Eshell V6.1 (abort with ^G) >>> 1> c(omac1),l(omac1),omac1:test(). >>> <<173,219,62,66,7,255,149,96,196,74,41,116,238,229,211,35>> >>> >>> this appears to work (at least, it doesn't crash with badarg. I don't >>> know whether the data is correct). Are you sure your aes key is 128, 192, >>> or 256 bits long? It's possible the crypto module is throwing badarg when >>> it detects an improper length key. >>> >>> On Tue, Feb 17, 2015 at 3:27 PM, Ryan Brown >>> wrote: >>> >>>> Thank you Felix. It looks like the aes_cbc_128_encrypt method is gone >>>> so I changed all to use crypto:block_encrypt(aes_cbc128, Key, IV, >>>> ToBeEncrypted) >>>> >>>> But alas, I'm still seeing the same error. >>>> >>>> On Tue, Feb 17, 2015 at 3:10 PM, Felix Gallo >>>> wrote: >>>> >>>>> I'm not super familiar with the crypto library, but it looks like its >>>>> function signatures changed significantly between 15B01 and 16B03. In >>>>> particular, it appears that some of the functions you are calling are no >>>>> longer in the library, and have been replaced with equivalents. >>>>> >>>>> I suggest opening >>>>> >>>>> http://erldocs.com/R15B01/crypto/crypto.html >>>>> >>>>> and >>>>> >>>>> http://erldocs.com/R16B03/crypto/crypto.html >>>>> >>>>> and seeing if you can figure out where the changes occurred. I >>>>> suspect those are the cause of your badargs. >>>>> >>>>> F. >>>>> >>>>> On Tue, Feb 17, 2015 at 1:55 PM, Ryan Brown >>>>> wrote: >>>>> >>>>>> Hello all, >>>>>> >>>>>> I am in the process of upgrading a legacy application from R15B01 to >>>>>> R16B03 in order to get SHA 384 support. However, I am getting an error >>>>>> creating my CMAC from the library located here: >>>>>> >>>>>> https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl >>>>>> >>>>>> For the life of me I cannot find the root cause. I am just receiving >>>>>> a badarg error pointing to line 74. >>>>>> >>>>>> Any guidance would be greatly appreciated. >>>>>> >>>>>> Thank you. >>>>>> >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> erlang-questions mailing list >>>>>> erlang-questions@REDACTED >>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>>> >>>>>> >>>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rvirding@REDACTED Thu Feb 19 22:13:54 2015 From: rvirding@REDACTED (Robert Virding) Date: Thu, 19 Feb 2015 22:13:54 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: An historical perspective: over the years there have been a number of attempts to add more traditional OO and classes to Erlang, and while many have worked they were never very long-lived. I think that that style of programming just doesn't fit well together with Erlang. There are a number of languages which mix functional and OO, for example scala, but personally I am sceptical to that. To really reap the benefits of functional programming you have to know, I mean really KNOW, that it won't be compromised somewhere else so that you can trust. If you can't trust it then what's the point, I might as while write C in a functional style. The bigger and more complex and more long-lived your application becomes the more important this is. It mightn't always feel the best but in the long-run and when things scale the better it becomes. And, yes of course, you can have programming rules but I also know that breaking a rule this little one time isn't going hurt anyone. Etc. Robert On 19 February 2015 at 16:06, Imants Cekusins wrote: > another thought: > > let's take JavaScript. > > Originally it was designed to be be used in certain ways. And what > people are doing with Javascript now? Various frameworks. Run it on > server, create classes, call plain vanilla funs, MVVM, templates. It > looks like Javascript, but is not vanilla Js anymore.. > > > So we add a class flavour to otp. Big deal. It's still Erlang OTP. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From matthias@REDACTED Thu Feb 19 22:32:32 2015 From: matthias@REDACTED (Matthias Lang) Date: Thu, 19 Feb 2015 22:32:32 +0100 Subject: [erlang-questions] Inlining in Erlang In-Reply-To: <7662590.02IB3hHcgi@changa> References: <7662590.02IB3hHcgi@changa> Message-ID: <20150219213232.GA23454@corelatus.se> Hi, On 18. February 2015, zxq9 wrote: > 1. A function wrapper around the value: > > some_value() -> 7. > > The function call involved will be optimized away by the compiler, but this ... > This sucks for various reasons and achieves the same effect as #1 in any case > (after compilation *literally* the same effect, Going off on a tangent: getting the compiler to act as you describe requires non-default options: | Inlining is never default; it must be explicitly enabled with a | compiler option or a -compile() attribute in the source module. | | To enable inlining, either use the inline option to let the compiler | decide which functions to inline or {inline,[{Name,Arity},...]} to | have the compiler inline all calls to the given functions. If the | option is given inside a compile directive in an Erlang module, | {Name,Arity} may be written as Name/Arity. | | http://www.erlang.org/doc/man/compile.html#file-1 I think HiPE, which isn't on by default, inlines by default. But I haven't checked. (I checked that the regular compiler doesn't inline by compiling to assembler, i.e. the 'S' option, and inspecting the code. I didn't check the beam loader, but I don't think it inlines things; if it does then that is surprising.) Matthias From gumm@REDACTED Thu Feb 19 22:50:07 2015 From: gumm@REDACTED (Jesse Gumm) Date: Thu, 19 Feb 2015 15:50:07 -0600 Subject: [erlang-questions] [ANN] Nitrogen 2.3 and SimpleBridge 2.0 Released Message-ID: Hello Fellow Erlangers, I'm happy to announce the release of the Nitrogen Web Framework 2.3 and Simple Bridge 2.0 As a brief review: * Nitrogen (http://nitrogenproject.com) is an event-driven Erlang web framework that uses Erlang records to generate HTML and Javascript. * SimpleBridge (http://github.com/nitrogen/simple_bridge) is an abstraction layer on top of existing Erlang webservers that provides a homogeneous interface the following Erlang servers (alphabetically): Cowboy, Inets, Mochiweb, Webmachine, Yaws. Guide to upgrading to Nitrogen 2.3: http://nitrogenproject.com/doc/upgrade2.3.html ****************** Nitrogen 2.3 ****************** Nitrogen 2.3 adds: * Convert to SimpleBridge 2.0 (See below), allowing for conversion to any supported webserver by changing a config variable and adding rebar dependencies. * Long-overdue websocket support added (with a safe fallback to ajax/comet, and broken connection detection/notification/reconnection) * A browser-based test system (validate that your interface is working properly in the browser and communicating with the server as expected). * More diverse routing options like a REST handler and "smart extensions" (a different entry point into a module based on request extension) * A debug crash handler (enabled by default) that gives more useful information to the client when crashing than just "Internal Server Error" * Improved Unicode handling * The usual: New elements, actions, API functions, documentation, etc (my favorite new element is the #sync_panel element, which attaches a panel to a comet pool, and any changes to it are broadcast to all other clients connected to the pool). * Nitrogen Changelog: https://github.com/nitrogen/nitrogen/blob/master/CHANGELOG.markdown ******************** SimpleBridge 2.0 ******************** This release was super fun to build, and adds a whole slew of new and interesting stuff. It has been fundamentally reworked: * Eliminated Parameterized Modules while retaining the ability to use the tuple-module syntax for backwards compatibility. The new "official" API is through the "sbw" module (for "simple bridge wrapper") * Added initializers for each server (supervisors and entry point modules) based on the simple_bridge.config file (setting up routing tables, bound ports and addresses, max post sizes, etc) * Added a simple_bridge_handler behavior, which you would use to define your application or framework's entry point (basically, the anchor translates the server's expected entry point into your application's handlers). * While each server responds in its own way to similar requests (lists vs binaries, or IP tuples vs IP Strings), SimpleBridge will now return consistent results regardless of the chosen server, and where applicable will work in a Type-In-Type-Out fashion (binary() -> binary(), list() -> list()). * Added websocket abstraction, using native websocket functionality for cowboy and yaws, and hijacking the socket for inets, mochiweb, and webmachine. It passes the Autobahn test suite. * Completely rewritten test suite, which now uses the same tests for each backend. SimpleBridge Changelog: https://github.com/nitrogen/simple_bridge/blob/master/CHANGELOG.markdown Overall, I'm pleased as punch with this release, and it's been a long time coming. I've had it running in production on my products for several weeks now without incident (I always run the releases in production before announcing the release). On a personal note, working on Nitrogen continues to give me a tremendous amount of joy. Indeed, it is one of those things that doesn't really feel like work, it's almost relaxing. Also, as those of you who were at Chicago Erlang Conference know, I'm co-authoring a book on Nitrogen development, which can be downloaded in its current beta form at: http://builditwith.com/nitrogen Finally, thanks to everyone who contributed code, submitted bug reports and issues, asked questions, and also submitted errata for the book. Every little bit helps and you folks are great for it! Thanks all again, and happy hacking! -Jesse P.S. Looking forward to seeing some of you tonight at Chicago Erlang User Group (http://www.meetup.com/ErlangChicago/events/220276271/) P.P.S The Raspberry Pi builds for Raspbian will be delayed a bit until my new Raspberry Pi gets delivered. All other binaries (Linux, OSX, Windows, and FreeBSD are ready to go). -- Jesse Gumm Owner, Sigma Star Systems 414.940.4866 || sigma-star.com || @jessegumm From imantc@REDACTED Thu Feb 19 22:59:28 2015 From: imantc@REDACTED (Imants Cekusins) Date: Thu, 19 Feb 2015 22:59:28 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: > there have been a number of attempts to add more traditional OO and classes to Erlang, and while many have worked they were never very long-lived. Probably for a good reason, too. Erlang is special in that it gives clear, simple blocks to build on. It does a number of things in a reliable way. The rest is up to programmer. You can add inheritance, types, ..ahem!.. classes - if you need them. Let's keep it like this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From felixgallo@REDACTED Thu Feb 19 23:17:05 2015 From: felixgallo@REDACTED (Felix Gallo) Date: Thu, 19 Feb 2015 14:17:05 -0800 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 In-Reply-To: References: Message-ID: I also would find that surprising, and indeed your code seems to crash on 15B01 as well, at least with my inputs. Is it possible that there is something else that happened along the way which is causing different inputs to be presented to the function, or some circumstance which is causing that branch to get triggered where it never has before? On Thu, Feb 19, 2015 at 1:11 PM, Ryan Brown wrote: > Thank you for the excellent clarification Felix. This code was written > five years ago and we are just trying to update the version of Erlang it's > running on. Everything seems to run fine on R15B (has been in production > w/o issue for five years). > > So, while I was able to refactor the code to work, I suppose I am still > scratching my head as to why this would have changed between R15 and R16. > I've read the release readme and don't see anything obvious. > > Best regards, > > Ryan > > On Thu, Feb 19, 2015 at 1:33 PM, Felix Gallo wrote: > >> A constructive note: it's hard for readers (e.g. me) to reason about >> what's happening without a full, minimal failing test case, including the >> data you're passing in. Just the act of creating a minimal failing test >> case is also a great debugging step that often illuminates/solves the >> problem (along the lines of 'rubber duck debugging' ( >> http://en.wikipedia.org/wiki/Rubber_duck_debugging)). For example, >> maybe you're passing in the wrong kind of data; that is very common and is >> frequently exposed when you type it in a second time and look at it. >> >> For the purposes of this discussion I created a test() function: >> >> test() -> >> X = <<1:128>>, >> Y = <<1:53>>, >> Z = <<1:1>>, >> pad_binary_128(X), >> pad_binary_128(Y), >> pad_binary_128(Z). >> >> and then I run it like so: >> >> Eshell V6.1 (abort with ^G) >> 1> c(a),l(a),a:test(). >> Line 100 >> Line 97 >> ** exception error: bad argument >> in function a:pad_binary_128/1 (a.erl, line 12) >> in call from a:test/0 (a.erl, line 22) >> >> and see your error when I am trying to use a 53 bit bitstring. >> >> In this particular scenario that matches the clause: >> >> pad_binary_128(Data) when bit_size(Data) < 128 -> >> io:format("Line ~p~n", [97]), >> pad_binary_128(<>); >> >> this appears to me be an excessively clever attempt to right-pad the >> binary with zeroes. In particular, the original author thought >> <> would construct a binary with one zero to the right, >> and then recursion would continue until the string was 128 bits long. >> >> As a debug step, let's break out the construction attempt from the >> function call: >> >> New = <>; >> pad_binary_128(New); >> >> now we get the error at the constructor. How exciting! >> >> So we turn to the documentation ( >> http://www.erlang.org/doc/programming_examples/bit_syntax.html) and see >> that you will get badarg errors when you attempt to construct a binary that >> has an unaligned byte boundary -- e.g., anything not divisible by 8. In >> this case, Data/binary could be attempting to convert an unaligned >> bitstring into a binary, which can't be done. >> >> In order to fix the problem in a short term way, you could change that to >> <> and it would run fine. But it also recurses for >> every single bit of padding, which is a little, ah, corkbrained. >> >> Better would be to refactor this code a little so it's a bit more >> sensible. I am by no means an erlang grandmaster but here's how I >> personally would do it. The specs pass dialyzer and there's a brief test >> suite that hits some of the high notes. >> >> https://github.com/Cloven/bitpad128/blob/master/bit_example.erl >> >> F. >> >> On Thu, Feb 19, 2015 at 11:02 AM, Ryan Brown >> wrote: >> >>> Thank you Felix. I did get that to work standalone. It appears that >>> there is something in the pad_binary method that I have not been able to >>> track-down. >>> >>> In a crude attempt to trace the issue down, I added a bunch of >>> io:formats and ran in the shell. >>> >>> pad_binary_128(Data) when bit_size(Data) > 128 -> >>> io:format("Line ~p~n", [89]), >>> {Kept, _Lost} = split_binary(Data, size(Data) - 1), >>> io:format("Line ~p~n", [94]), >>> pad_binary_128(Kept); >>> pad_binary_128(Data) when bit_size(Data) < 128 -> >>> io:format("Line ~p~n", [97]), >>> pad_binary_128(<>); >>> pad_binary_128(Data) -> >>> io:format("Line ~p~n", [100]), >>> Data. >>> >>> This is the output I get: >>> >>> Line 97 >>> ** exception error: bad argument >>> in function omac1:pad_binary_128/1 (src/omac1.erl, line 97) >>> in call from omac1:cmac_aes_cbc_128/6 (src/omac1.erl, line 78) >>> >>> So, it almost seems like there may be a difference in the way that >>> bit_size/1 is handled in R1603. However, I do not see anything that >>> stands-out to me in the docs. >>> >>> >>> http://erldocs.com/R15B01/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 >>> >>> http://erldocs.com/R16B03/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 >>> >>> Thanks in advance. >>> >>> Best, >>> >>> Ryan >>> >>> On Tue, Feb 17, 2015 at 5:21 PM, Felix Gallo >>> wrote: >>> >>>> I made your same changes to the module, and also added the following >>>> function to the module: >>>> >>>> test() -> >>>> Key = <<1:128>>, >>>> Data = <<1:128>>, >>>> generate_tag_aes_cbc_128(Key, Data). >>>> >>>> and when run in a shell: >>>> >>>> Eshell V6.1 (abort with ^G) >>>> 1> c(omac1),l(omac1),omac1:test(). >>>> <<173,219,62,66,7,255,149,96,196,74,41,116,238,229,211,35>> >>>> >>>> this appears to work (at least, it doesn't crash with badarg. I don't >>>> know whether the data is correct). Are you sure your aes key is 128, 192, >>>> or 256 bits long? It's possible the crypto module is throwing badarg when >>>> it detects an improper length key. >>>> >>>> On Tue, Feb 17, 2015 at 3:27 PM, Ryan Brown >>>> wrote: >>>> >>>>> Thank you Felix. It looks like the aes_cbc_128_encrypt method is gone >>>>> so I changed all to use crypto:block_encrypt(aes_cbc128, Key, IV, >>>>> ToBeEncrypted) >>>>> >>>>> But alas, I'm still seeing the same error. >>>>> >>>>> On Tue, Feb 17, 2015 at 3:10 PM, Felix Gallo >>>>> wrote: >>>>> >>>>>> I'm not super familiar with the crypto library, but it looks like its >>>>>> function signatures changed significantly between 15B01 and 16B03. In >>>>>> particular, it appears that some of the functions you are calling are no >>>>>> longer in the library, and have been replaced with equivalents. >>>>>> >>>>>> I suggest opening >>>>>> >>>>>> http://erldocs.com/R15B01/crypto/crypto.html >>>>>> >>>>>> and >>>>>> >>>>>> http://erldocs.com/R16B03/crypto/crypto.html >>>>>> >>>>>> and seeing if you can figure out where the changes occurred. I >>>>>> suspect those are the cause of your badargs. >>>>>> >>>>>> F. >>>>>> >>>>>> On Tue, Feb 17, 2015 at 1:55 PM, Ryan Brown >>>>>> wrote: >>>>>> >>>>>>> Hello all, >>>>>>> >>>>>>> I am in the process of upgrading a legacy application from R15B01 to >>>>>>> R16B03 in order to get SHA 384 support. However, I am getting an error >>>>>>> creating my CMAC from the library located here: >>>>>>> >>>>>>> https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl >>>>>>> >>>>>>> For the life of me I cannot find the root cause. I am just receiving >>>>>>> a badarg error pointing to line 74. >>>>>>> >>>>>>> Any guidance would be greatly appreciated. >>>>>>> >>>>>>> Thank you. >>>>>>> >>>>>>> >>>>>>> >>>>>>> _______________________________________________ >>>>>>> erlang-questions mailing list >>>>>>> erlang-questions@REDACTED >>>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From e@REDACTED Thu Feb 19 23:21:35 2015 From: e@REDACTED (e@REDACTED) Date: Thu, 19 Feb 2015 23:21:35 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: <54E661EF.70003@bestmx.net> On 02/19/2015 10:13 PM, Robert Virding wrote: > An historical perspective: over the years there have been a number of > attempts to add more traditional OO and classes to Erlang, and while many > have worked they were never very long-lived. I think that that style of > programming just doesn't fit well together with Erlang. There are a number > of languages which mix functional and OO, for example scala, but personally > I am sceptical to that. To really reap the benefits of functional > programming you have to know, I mean really KNOW, that it won't be > compromised somewhere else so that you can trust. If you can't trust it > then what's the point, I might as while write C in a functional style. > > The bigger and more complex and more long-lived your application becomes > the more important this is. It mightn't always feel the best but in the > long-run and when things scale the better it becomes. And, yes of course, > you can have programming rules but I also know that breaking a rule this > little one time isn't going hurt anyone. Etc. all in all you can think of an Erlang module as an object. and it gives you much better "OOP" than traditional OOP. From ok@REDACTED Fri Feb 20 01:07:04 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 20 Feb 2015 13:07:04 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: <4C1DAA73-A61D-4695-A323-2C014A78EF2E@cs.otago.ac.nz> On 20/02/2015, at 2:04 am, Imants Cekusins wrote: >> So much time spent for removing one State variable from a few function calls. > > much more time will be saved when refactoring from now on. > > imagine: > most funs will now have signature: > > -spec a(pid()) -> ok. > > and most function bodies will look like: > check(Pid), > update(Pid), > return(Pid). > > it will be a breeze now. Why? What I'm seeing here looks like strongly imperative code. There are presumably dependencies here (e.g., "you must call check/1 before you call update/1") that are not stated and cannot be checked. If you have -spec check(pid()) -> checked(). -spec update(checked()) -> updated(). -spec return(updated()) -> result(). then there is only one way to hook these steps together that makes sense, and the Dialyzer can check that return(update(check(Pid))) makes sense and that return(check(update(Pid))) does not. (Note that the Pid can be part of checked() and updated() types.) The way I understand it, the thing about doing refactoring at speed is having tool support, whether it's static verification, good unit testing, or both, that lets you rapidly check each small step that it hasn't broken anything. Having most of your functions with one uninformative specificagtion seems to me like a recipe for making refactoring error-prone. From ok@REDACTED Fri Feb 20 01:16:36 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 20 Feb 2015 13:16:36 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> Message-ID: <6726B766-5D8C-4413-B805-2A52FE939F5D@cs.otago.ac.nz> On 20/02/2015, at 2:12 am, Imants Cekusins wrote: > a fun can return just what it did, without > {Return, State} > > so no more > S1 = a(State), > S2 = b(S1) > > simply > a(Pid) > b(Pid) > OK, this is where Haskell shines. Haskell exploits the type system to let you hide the plumbing, while the plumbing remains _there_. However, you still have that Pid to pass around all the time, so instead of simply threading state values through function calls, you are passing around an armed grenade instead; you're still not *hiding* the plumbing the way you can in Haskell. Now I begin to see where you are coming from, but if renumbering state variables was a big part of the time you spent refactoring, you were probably doing it wrong, like maybe having big function bodies with lots of stateful steps instead of little function bodies with at most say three stateful steps. Seeing REAL CODE would be a huge help in discussions like this. I can't emphasise that strongly enough. REAL CODE. As in, not little ad hoc snippets, but actual chunks of the code you are actually trying to work on. What we really need is state monad combinators for Erlang. From ok@REDACTED Fri Feb 20 01:26:16 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 20 Feb 2015 13:26:16 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> Message-ID: <804080AC-5C9D-45F1-BC5A-A38DD01650D0@cs.otago.ac.nz> On 20/02/2015, at 2:16 am, Imants Cekusins wrote: >> "ok, a method called 'fred'. Wonder what it does?" > > well let's just say if I understand program flow, this is not a > problem. If it is unfamiliar code, then by definition I don't understand the control flow. Last week, a test case failed in my Smalltalk system. I had refactored A -> C to A -> B -> C. This was in most respects a nice win -- half of C had disappeared -- and I'd been using the new C for a while. But the new test case used a different constructor, and suddenly it blew up in a strange way. It took me an hour to disentangle the control flow, and I had written every line of it all. There were actually two bugs. (1) a method was being called during construction when it expected to be called after. The control flow had changed. (2) a method override that wasn't needed now that B was there still existed and was being called. A control flow should have changed but hadn't. As Dijkstra pointed out back in the 60s, when we have to play computer in order to figure things out, we're in trouble. > If I do not understand it, long explicit signatures are not > of much help. That's not my experience. In particular, a function foo(State0, Input) -> {State1, Output} is a function I can understand in isolation, and I can use type checking to constrain its uses. A function foo(Pid, Input) -> Output is something I can't understand without understanding a great deal about the process Pid refers to, without any type/state system telling me about that. From ok@REDACTED Fri Feb 20 01:51:54 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 20 Feb 2015 13:51:54 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> Message-ID: <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> On 20/02/2015, at 3:34 am, Imants Cekusins wrote: > well the "state" gs calls would be quite fail-proof: get_state, > set_state. The gs would only hold the state and make it accessible > from anywhere. > > the rest of the program flow stays pretty much intact, no? > > > to operate on the state variables I would still need to get state, > assign it to a local variable in a function, then pass it to some > function to work on this var. > > I do not aim to completely eliminate args. e.g. there would still be funs like > parse(Bin) -> #parsed{}. > > it would be obvious from parse/1 signature that it does not change the > state - another benefit. Possibly I did not get enough sleep, but somehow I just couldn't understand this. Let's consider three functions. I'll use Haskell syntax because I like it. pure :: In -> Out reader :: State -> In -> Out writer :: State -> In -> (State, Out). From this it is obvious that - pure does not depend on or change State - reader depends on State but does not change it - writer depends on State and may (but need not) change it. I could write this in C as Out pure(In x) /*@ globals @*/ /*@ modifies nothing @*/; Out reader(In x) /*@ globals state @*/ /*@ modifies nothing @*/; Out writer(In x) /*@ globals state @*/ /*@ modifies state @*/; and similar markup is available for Ada and Java. But using your approach pure :: In -> Out reader :: Pid -> In -> Out writer :: Pid -> In -> Out I *cannot* distinguish a function that just reads the state from a function that changes it. One of the reasons I used to love the programming language Clean, before they decided to concentrate on Windows, is that Clean makes it easy to *BREAK UP THE STATE* into small pieces. For example, I can write a Clean function that modifies one file WITHOUT that function being able to touch anything else in the file system. Shoving *all* the state in one object and "mak(ing) it accessible everywhere" increases the potential for errors. Finally, it must have occurred to you that passing a state record/map around and fishing stuff out of it is CHEAP, while sending a message to another process, having it receive, sending a message back, and receiving that is EXPENSIVE. As an interprocess mechanism, it's cheap enough to use whenever appropriate. As a substitute for assignment statements, OUCH. Have you measured this cost? Had you considered the possibility of developing whatever-it-is in Elixir? http://elixir-lang.org/crash-course.html Elixir allows rebinding variables, so you can do {state,y} = f State, x {state,z} = g State, y From ok@REDACTED Fri Feb 20 02:06:36 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 20 Feb 2015 14:06:36 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> Message-ID: <433E9AC6-3996-4B3B-878D-8B63E42E6A12@cs.otago.ac.nz> On 20/02/2015, at 3:53 am, Imants Cekusins wrote: > this approach would hopefully run programs very similarly to how > conventionally written programs would run. Ah! You mean "badly!" > I mean, in terms of program > output, memory consumption, speed. Explicit state threading makes no difference to program output and is likely to take LESS memory than your "state process" approach. If you are interested in speed, "state process" is going to take a lot MORE time than threading a record. > > I tried writing in the traditional way. It took me too long. This is a fact about you now and your previous experience. It is not a fact about Erlang or about pracniques. I used to see the same thing in Prolog. People would insist on simulating assignment statements using the data base, slowing their programs down by huge factors rather than learn how to do without them. While at Quintus, I made the mistake of showing one customer how to make his program simpler and run 700 times faster. We lost that customer! If you are doing FP right, you won't HAVE a massive state that needs passing around everywhere. You may well have a main "server" loop that carries around a fair bit of state, but that should normally pass off to the handlers *just* the bits they need, and the revised values, should there be any, don't get written back to the main state until the handler is done. Amongst other things, having state that can be and is mutated practically anywhere is DEATH to meaningful exception handling. One of the things about Erlang that had me nearly weeping for joy when I understood it is that you aren't faced with the disgusting nightmare that you are in PL/I, Ada, C++, Java, and so on: "OK, that didn't work, WHAT HAPPENED TO MY STATE?" Try reading the Ada design documents at some point. They are unusually honest. Compiler optimisations mean that the state that was perceived by the code that raised an exception probably won't correspond to the state that is perceived by a handler. From imantc@REDACTED Fri Feb 20 02:10:37 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 02:10:37 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <804080AC-5C9D-45F1-BC5A-A38DD01650D0@cs.otago.ac.nz> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <804080AC-5C9D-45F1-BC5A-A38DD01650D0@cs.otago.ac.nz> Message-ID: > if renumbering state variables was a big part of the time you spent refactoring, you were probably doing it wrong, I may have written code in suboptimal way, yes. Refactoring took long because I rewrote several applications several times over. It is simple a lot of work. The code worked both before and after refactoring. This was not an issue. Because of complex signatures I needed to refer to different files often. When looking at other files, new questions flooded in, leading to other files, forgetting what I was looking for. Anyway, I found my answer. Busy time ahead: I will rewrite everything again, then again etc. Please remember: I do not impose or "sell" this approach. I asked a question, found an answer, share it with those who faced similar problem. Choice is good. -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Fri Feb 20 02:23:27 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 02:23:27 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> Message-ID: > sending a message to another process, having it receive, sending a message back, and receiving that is EXPENSIVE. I am going to call - not cast the gs. The gs will never be busy handling any other calls. Does it make a difference? In any case, whatever the cost, while in the development phase, it's ok. Before testing & production I can switch to passing the state if it makes noticeable difference. Thank you very much for your advice, Richard! I am sure that others benefit, too. -------------- next part -------------- An HTML attachment was scrubbed... URL: From imantc@REDACTED Fri Feb 20 03:31:55 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 03:31:55 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <433E9AC6-3996-4B3B-878D-8B63E42E6A12@cs.otago.ac.nz> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> <433E9AC6-3996-4B3B-878D-8B63E42E6A12@cs.otago.ac.nz> Message-ID: > The way I understand it, the thing about doing refactoring at speed is having tool support, whether it's static verification, good unit testing, or both, that lets you rapidly check each small step that it hasn't broken anything. > Having most of your functions with one uninformative specification seems to me like a recipe for making refactoring error-prone. So far the time spent between debugging and checking signatures was ~ 100hr = 20:80% Now I expect ~ 50hr = 80:20% - is still worth the change > actual chunks of the code you are actually trying to work on. sorry, I can't. commercial closed source. pure :: In -> Out reader :: Pid -> In -> Out writer :: Pid -> In -> Out > I *cannot* distinguish a function that just reads the state from a function that changes it. renaming functions is very quick process. I can add very long comments, too. >> I tried writing in the traditional way. It took me too long. > This is a fact about you now and your previous experience. It is not a fact about Erlang or about practices. yes, I've been writing about my own experience all the time. I did not try to evaluate the language or common development standards. I tried to find an answer to my problem. From ok@REDACTED Fri Feb 20 04:11:25 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 20 Feb 2015 16:11:25 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> <433E9AC6-3996-4B3B-878D-8B63E42E6A12@cs.otago.ac.nz> Message-ID: <5B95F049-5A60-473A-9244-A307FBBF4B41@cs.otago.ac.nz> On 20/02/2015, at 3:31 pm, Imants Cekusins wrote: >> I *cannot* distinguish a function that just reads the state from a > function that changes it. > > renaming functions is very quick process. We weren't talking about the *names* of functions. > I can add very long comments, too. I at least was talking about things the system can check for you. Comments are not one of those things. OK, so commercial closed source cannot be shown, but in the time it's taken to have this debate, about four pages of Erlang code *realistically* like the code in question could have been written. Do you have measurements for the cost of putting state in a separate process yet? From ok@REDACTED Fri Feb 20 04:27:19 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Fri, 20 Feb 2015 16:27:19 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> Message-ID: On 20/02/2015, at 2:23 pm, Imants Cekusins wrote: > > sending a message > to another process, having it receive, sending a message back, and > receiving that is EXPENSIVE. > > I am going to call - not cast the gs. Not relevant. > The gs will never be busy handling any other calls. Does it make a difference? Not much. I just did a benchmark looping around a million times. There was no contention in that case. Threading state through: 10 msec. Using a state process that was as lightweight as possible: 1670 msec. This wasn't native compiled, and it didn't do any real work, so I don't expect real code to be 167 times slower using a state process. But I do expect it to be a lot slower. > In any case, whatever the cost, while in the development phase, it's ok. Faster code means you can afford to run more tests means faster development. Ceteris paribus. > From imantc@REDACTED Fri Feb 20 04:28:53 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 04:28:53 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <5B95F049-5A60-473A-9244-A307FBBF4B41@cs.otago.ac.nz> References: <0B886376-E388-401A-9893-5BBDC3A3A56C@cs.otago.ac.nz> <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5F6AD.9050009@research.att.com> <2D87AC37-62F9-480F-9E7F-31E85870FA4C@basho.com> <433E9AC6-3996-4B3B-878D-8B63E42E6A12@cs.otago.ac.nz> <5B95F049-5A60-473A-9244-A307FBBF4B41@cs.otago.ac.nz> Message-ID: > I at least was talking about things the system can check for you. With this approach extensive type checks can be done on assignment. > Erlang code *realistically* like the code in question could have been written. these are almost textbook-like OTP callback modules which call methods in worker modules, which in turn call other worker modules. nothing fancy. > Do you have measurements for the cost of putting state in a separate process yet? good point. it will take time. however this is time well spent. checking signatures which are likely to change was wasted time. From imantc@REDACTED Fri Feb 20 04:36:04 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 04:36:04 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> Message-ID: > Threading state through: 10 msec. Using a state process that was as lightweight as possible: 1670 msec. > This wasn't native compiled, and it didn't do any real work, so I don't expect real code to be 167 times slower using a state process. But I do expect it to be a lot slower. thank you very much for running this test! appreciate this. with this approach I may group / chunk state modification more easily. refactoring will be easier and faster. I will focus on function body, not 10 signatures in the chain. From imantc@REDACTED Fri Feb 20 04:43:12 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 04:43:12 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> Message-ID: > I just did a benchmark looping around a million times. There was no contention in that case. > Threading state through: 10 msec. Using a state process that was as lightweight as possible: 1670 msec. just thought about it: 1.7 sec for a million calls? can live with this ok ;) From rizkhan@REDACTED Fri Feb 20 05:44:47 2015 From: rizkhan@REDACTED (Rizwan Khan) Date: Fri, 20 Feb 2015 04:44:47 +0000 Subject: [erlang-questions] Erlang based C2ISR system In-Reply-To: <1488951.nvtsoKpDl8@changa> References: <1488951.nvtsoKpDl8@changa> Message-ID: Thanks a lot for the input Craig. Highly appreciated. Do you have any experience with Safir SDk? Rizwan Khan On Tue, Feb 17, 2015 at 9:05 AM, zxq9 wrote: > On 2015?2?17? ??? 11:47:32 Rizwan Khan wrote: > > Any one knows if Erlang is being used anywhere for Command and Control or > > ISR systems which are normally for the armed forces. > > > > I am not too sure if that would be a good fit either. May be in terms for > > distributed computing and surely not for image processing related > > applications. > > A somewhat long-winded response follows, much of it anecdotal. I'm trying > to > give enough background for the OP to understand the situation that exists > at > the C2 level, the tactical level, and what I have seen in a C2&T project > I've > worked on, and what I have externally observed about another very similar > one. > > ~~~~~~ > > I doubt it is. In any case, of the bajillion or so supposedly > interoperable C2 > systems I ever took the time to peek into, every one seemed to be written > against a different combination of language/platform/environment > assumptions. > Whether or not Erlang is a good fit for C2 (and in many cases it certainly > may > be), it seems to have about zero mindshare within the military. > > At a larger TOC there was usually a guy or section whose task it was to > aggregate data so various folks could access it or use it -- more often > than > not, though, a TOC (whether a FOB, JSOTF, JSOTF-forward, or an *actual* > TOC) > is a blackhole for information. > > In SF our 18E/F/Cs (or whoever on the team had significant computer > knowledge > and could work with the 18E) would deal with receiving, say, UAV imagery > directly from the pilot's direct feed or (usually better) from whatever > laptop > software could talk to it, convert it to something he could send over the > air, > and relay it that way. Data from outside the team might be handled the same > way (if there was time), but usually a one-off system existed for each > type of > asset we might be working with (like an application that handles one > specific > type of video from one particular source, an entire > hardware-kit-in-a-suitcase > for receiving P3 imagery live, a special video box with no digital output > so > we could (maybe) watch a particular feed, etc.) and very often there just > isn't time to mess with aggregation in a useful way until long after the > fun > is over. > > Of course, at the TOC, where all the folks who don't actually do anything > operational hang out, all sorts of data is supposedly aggregated -- but > I've > seen exactly zero evidence of that in practice. I suspect that roughly half > the blame for the blackholiness of TOCs (and other echelons beyond reality > in > general) belongs to the bureaucratic sloth that manifests in any large, > rigid > organization, and the other half probably belongs to the fact that every > single system is completely different from every other system (and that > itself > is a product of the nature of acquisitions within large bureaucracies). > Sorting through all the miles of piles of data that pour in to a TOC after- > the-fact is a much lower priority than ongoing operations (or than printing > random memoranda about authorized holster models, etc.), so the monumental > task of untangling the digital/analog Gordian Knot appears to rarely be > undertaken in a serious way -- at least from what I witnessed. I don't > think > there is really any way around this, though the situation could certainly > be a > bit less ridiculous. > > So with that anecdotal picture in mind, the search for use cases of Erlang > in > C2 systems (of any kind) is either going to be extremely difficult (sifting > through thousands of one-off systems by vendors reluctant to expose their > tools), or purely academic. > > Colt is doing some interesting work on an integrated C2 system for the > tactical level, but I don't think any Erlang is involved there (mostly C > and > Java, from the looks of it -- I've never looked inside, though). I was > leading > a project last year at a company developing a conceptually related system > which had very different origins and a different focus (The company > imploded > midway through! Very frustrating!). While I was actually going to use > Erlang > for the (somewhat limited) tasks that existed server-side, much of the > rest of > the project code was C and Scala. A lot of what was required was either > directly dependent on unique hardware or had to run on Android, everything > required careful power usage, most of the system was peer-oriented up to a > certain layer, and Erlang just did not fit most of the roles. > > Regards, > -Craig > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zxq9@REDACTED Fri Feb 20 06:27:30 2015 From: zxq9@REDACTED (zxq9) Date: Fri, 20 Feb 2015 14:27:30 +0900 Subject: [erlang-questions] Erlang based C2ISR system In-Reply-To: References: <1488951.nvtsoKpDl8@changa> Message-ID: <2138611.aU599MIrbZ@changa> On 2015?2?20? ??? 04:44:47 you wrote: > Thanks a lot for the input Craig. Highly appreciated. > > Do you have any experience with Safir SDk? No. It looks interesting, but I don't know anything about it. My main personal interest in battlefield systems is building things that help inform the E-6 (Staff Sergeant/squad leader) and below -- because those are the actual tactical decision makers. The higher command and control elements already have too many toys that present them with the false impression that they can effectively micromanage combat in progress, and the privates and sergeants who actually do the work are still relatively tech-blind (NODs, radios and lasers are not what addresses this). A close secondary is concepts that can overturn our assumptions about what "engagement" and "weapon" mean. A close third is making money. Unfortunately pursuit of the third has pretty consistently meant that I have to avoid the first two, because nobody is interested in building a world where the primary infantry weapon is not the rifle, or making sure Joe can locate/see whatever John just reported. Safir looks like it is mostly used for creating systems where the command/staff is treated as the people who need to know everything first -- but it can probably be used to build a system that reverses that assumption as well. In any case I wouldn't be able to tell unless I messed with it a bunch first. We could continue this discussion off-list if you'd like; I think not many folks here are into this sort of thing. -Craig From mailparmalat@REDACTED Fri Feb 20 10:10:26 2015 From: mailparmalat@REDACTED (Steven) Date: Fri, 20 Feb 2015 11:10:26 +0200 Subject: [erlang-questions] beam.smp[10507]: segfault at 00003001dc88b8f0 rip 00000000004ee448 rsp 0000000043b7ec30 error 4 Message-ID: Good day everyone We recently experienced a segmentation fault on one of our runtimes. The runtime was carrying traffic and been running for about a year. Running R13B4 64bit with smp enabled and OS is redhat 5.2 64bit. The runtime is started with +S 8 +A 32 and not using any nifs. Unfortunately, no core dump and this is the first time we seeing it. There's another 5 nodes with the same deployment and hasn't happened on those runtimes (touch wood). Below is the information I could extract. I can enable core dump but won't know when this will happen again. *Erlang /usr/local/erlang/R13B-4/lib/erlang/bin/erl Erlang R13B04 (erts-5.7.5) [source] [64-bit] [smp:16:16] [rq:16] [async-threads:0] [hipe] [kernel-poll:false] Eshell V5.7.5 (abort with ^G) *beam.smp strings -a /usr/local/erlang/R13B-4/lib/erlang/erts-5.7.5/bin/beam.smp | fgrep GCC | more GCC: (GNU) 4.1.2 20071124 (Red Hat 4.1.2-41) *Disassembled the beam.smp, instruction pointer where the fault occurred shown below. cat beam.smp.objdump | grep -C 10 4ee448 4ee3fe: 48 3b 54 24 08 cmp 0x8(%rsp),%rdx 4ee403: 48 89 74 24 68 mov %rsi,0x68(%rsp) 4ee408: 74 12 je 4ee41c 4ee40a: 48 8b 35 87 21 37 00 mov 3613063(%rip),%rsi # 860598 4ee411: bf 09 00 00 00 mov $0x9,%edi 4ee416: ff 15 74 21 37 00 callq *3613044(%rip) # 860590 4ee41c: 4d 85 ff test %r15,%r15 4ee41f: 0f 84 b1 08 00 00 je 4eecd6 4ee425: 48 8b 54 24 58 mov 0x58(%rsp),%rdx 4ee42a: 48 39 54 24 68 cmp %rdx,0x68(%rsp) 4ee42f: 75 17 jne 4ee448 4ee431: eb 52 jmp 4ee485 4ee433: 48 83 f8 02 cmp $0x2,%rax 4ee437: 0f 84 dc 05 00 00 je 4eea19 4ee43d: 48 83 c2 08 add $0x8,%rdx 4ee441: 48 39 54 24 68 cmp %rdx,0x68(%rsp) 4ee446: 74 3d je 4ee485 4ee448: 48 8b 32 mov (%rdx),%rsi 4ee44b: 48 89 f0 mov %rsi,%rax 4ee44e: 83 e0 03 and $0x3,%eax 4ee451: 48 83 f8 01 cmp $0x1,%rax 4ee455: 0f 84 eb 04 00 00 je 4ee946 4ee45b: 73 d6 jae 4ee433 4ee45d: 48 89 f0 mov %rsi,%rax 4ee460: 83 e0 3c and $0x3c,%eax 4ee463: 74 d8 je 4ee43d 4ee465: 48 83 f8 04 cmp $0x4,%rax 4ee469: 4c 8d 4a 08 lea 0x8(%rdx),%r9 4ee46d: 0f 1f 00 nopl (%rax) 4ee470: 0f 84 5f 07 00 00 je 4eebd5 4ee476: 48 c1 ee 06 shr $0x6,%rsi 4ee47a: 49 8d 14 f1 lea (%r9,%rsi,8),%rdx 4ee47e: 48 39 54 24 68 cmp %rdx,0x68(%rsp) 4ee483: 75 c3 jne 4ee448 4ee485: 48 8b bd 20 02 00 00 mov 0x220(%rbp),%rdi 4ee48c: 48 39 fb cmp %rdi,%rbx 4ee48f: 0f 87 27 08 00 00 ja 4eecbc 4ee495: 48 8b b5 10 02 00 00 mov 0x210(%rbp),%rsi 4ee49c: 48 39 75 10 cmp %rsi,0x10(%rbp) 4ee4a0: 48 8b 44 24 58 mov 0x58(%rsp),%rax 4ee4a5: 48 0f 44 44 24 68 cmove 0x68(%rsp),%rax 4ee4ab: 48 83 bd 38 02 00 00 cmpq $0x0,0x238(%rbp) 4ee4b2: 00 4ee4b3: 48 89 9d 20 02 00 00 mov %rbx,0x220(%rbp) Any help or knowledge would be appreciated. Thanks all Regards, Steven -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Fri Feb 20 11:20:22 2015 From: ok@REDACTED (ok@REDACTED) Date: Fri, 20 Feb 2015 23:20:22 +1300 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> Message-ID: <63abe0672ee003009deb6f40673fa327.squirrel@chasm.otago.ac.nz> >> Threading state through: 10 msec. > Using a state process that was as lightweight as possible: 1670 msec. > >> This wasn't native compiled, and it didn't do any real work, so I > don't expect real code to be 167 times slower using a state process. > But I do expect it to be a lot slower. > > thank you very much for running this test! appreciate this. I've now extended the measurements, on a different machine. %% All measurements are milliseconds for 10,000,000 iterations of %% a loop counting down. %% c(foo). c(foo, [native]). method %% 140 50 pass a number around %% 380 100 pass {V,N}, build new N %% 630 410 process dictionary, atom key %% 9260 9150 other process, use dec %% 16310 16010 state held in other process, get/put two messages each. The relevant ratio would seem to be 16010/100 = 160.1 16010 ms for 10,000,000 iterations is 1.601 sec for 1,000,000 iterations, or 1.6 ?sec for 1 iteration. Now each iteration does four message sends, so that's 0.4 ?sec per !+receive. Stripped to the bone, using 'dec' instead of {put,_,N}, so that each iteration does three message sends, for 0.3 ?sec per !+receive. The faster state process used this loop: state_loop2(N, Pid) -> receive get -> Pid!N, state_loop2(N, Pid) ; dec -> state_loop2(update(N), Pid) ; eof -> ok end. to keep the messages as small as possible and to eliminate a reply for 'dec'. I can see no advantage to putting state in another process compared with putting state in the process dictionary. From imantc@REDACTED Fri Feb 20 12:26:53 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 12:26:53 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <63abe0672ee003009deb6f40673fa327.squirrel@chasm.otago.ac.nz> References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> <63abe0672ee003009deb6f40673fa327.squirrel@chasm.otago.ac.nz> Message-ID: > I've now extended the measurements, on a different machine. > The relevant ratio would seem to be 16010/100 = 160.1 thank you very much! very useful. > I can see no advantage to putting state in another process compared with putting state in the process dictionary. I thought pd suffers some memory drawbacks? The advantages are: 1) gc is as good as with any gs; 2) there is some control over what happens with the state after the main otp process crashes; 3) the "state" gs can be accessed from another process; 4) the state can be moved to another node From n.oxyde@REDACTED Fri Feb 20 12:35:29 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Fri, 20 Feb 2015 12:35:29 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> Message-ID: <52E7391D-2CCC-4C35-938B-91D752B83602@gmail.com> Le 20 f?vr. 2015 ? 04:36, Imants Cekusins a ?crit : > with this approach I may group / chunk state modification more easily. > refactoring will be easier and faster. I will focus on function body, > not 10 signatures in the chain. Did it never occur to you that maybe your code is just badly organised? From imantc@REDACTED Fri Feb 20 12:40:48 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 12:40:48 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> <63abe0672ee003009deb6f40673fa327.squirrel@chasm.otago.ac.nz> Message-ID: > The advantages are: 5) modifications of the state may be duplicated to a db From imantc@REDACTED Fri Feb 20 12:44:01 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 12:44:01 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: <52E7391D-2CCC-4C35-938B-91D752B83602@gmail.com> References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> <52E7391D-2CCC-4C35-938B-91D752B83602@gmail.com> Message-ID: > Did it never occur to you that maybe your code is just badly organised? it may be. but this is another topic. let's not discuss it here, please. I do not impose this approach. some however may find it useful. From imantc@REDACTED Fri Feb 20 12:56:41 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 12:56:41 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> <63abe0672ee003009deb6f40673fa327.squirrel@chasm.otago.ac.nz> Message-ID: > The advantages are: 6) types or even values themselves may be checked on set From e@REDACTED Fri Feb 20 13:34:50 2015 From: e@REDACTED (e@REDACTED) Date: Fri, 20 Feb 2015 13:34:50 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: <54E729EA.6040306@bestmx.net> > yaws or mochiweb? not mochiweb (too complicated) > mnesia or mongoDB? not mongo. simply not. mnesia seems natural/native solution (at least for the beginning) > XML or JSon? not XML. XML is just another name of the Void. no kidding. saying XML you specify nothing. JSON is a subset of JS. it is very convenient for browsers. i use it. also, sometimes i use JS to convey info from my server to a client (for example: "foo(a1,a2,a3);") > intellij idea or eclipse? not eclipse. it is atrocious! > Win or Linux are you kidding???? P.S. i enjoy the zxq9's answer -- very thoughtful. From vincent.dephily@REDACTED Fri Feb 20 13:44:23 2015 From: vincent.dephily@REDACTED (Vincent de Phily) Date: Fri, 20 Feb 2015 13:44:23 +0100 Subject: [erlang-questions] Fwd: Figuring out proper ssl certificate settings with 17.3 In-Reply-To: <2200058.cD7JN7KKEC@moltowork> References: <4306941.X6676PlrAe@moltowork> <2200058.cD7JN7KKEC@moltowork> Message-ID: <12631081.mHgd8Kso8B@moltowork> On Thursday 19 February 2015 18:43:26 Vincent de Phily wrote: > On Thursday 22 January 2015 21:45:08 Ingela Andin wrote: > > If you want to handle > > incorrect clients by building the chain to the client certificate on the > > server side , if possible, you need to do that in the verify_fun when it > > fails and then call public_key:pkix_path_validation again with the chain > > that you built. > > I didn't try this yet, but I verified that > > > {partial_chain, fun(CAs) -> {trusted_ca,hd(CAs)} end} > > "solves" my issue but is basically a verify_none. It seems there's some > functionality overlap between partial_chain and verify_fun, but I'm not 100% > sure when to use which. FWIW, I managed to get the behaviour I expect (can you spot a bug ?) using either verify_fun or partial_chain: Verif = fun(Cert,{bad_cert, _}, _) -> case public_key:pkix_path_validation(TrustedCA,[Cert],[]) of {ok, _} -> {valid, P}; {error, Reason} -> {fail, Reason} end; (_, {extension, Ex}, _) -> {unknown, []}; (_, valid, _) -> {valid, []}; (_, valid_peer, _) -> {valid, []} end, Partial = fun(Chain) -> case public_key:pkix_path_validation(TrustedCA,Chain,[]) of {ok, _} -> {trusted_ca,hd(Chain)}; {error, Reason} -> Reason end end, Connecting with {fail_if_no_peer_cert, true}, {verify, verify_peer}, {cert, MyCert}, {key, MyKey}, {cacerts, [TrustedCA]} and either {verify_fun, {Verif,[]}} or {partial_chain, Partial} Same config for both the client and the server, only the values of TrustedCA and MyCert/MyKey change. At this stage, I'm still unsure wether using verify_fun or partial_chain makes more sense (or is faster). > I'd like OTP to do the "peer-sent cert chain is signed by one of the localy- > trusted CAs" step for me. I realize that I could do it myself using the > public_key module, but I find it very surprising that my usecase would be > so unusual that it isn't supported out of the box. A peer that sends the > smallest chain that can be verified by the other peer isn't "incorrect". These concerns are still valid. If feels strange that my version of verify_fun does something different than OTP's version. -- Vincent de Phily Mobile Devices +33 (0) 142 119 325 +353 (0) 85 710 6320 Warning This message (and any associated files) is intended only for the use of its intended recipient and may contain information that is confidential, subject to copyright or constitutes a trade secret. If you are not the intended recipient you are hereby notified that any dissemination, copying or distribution of this message, or files associated with this message, is strictly prohibited. If you have received this message in error, please notify us immediately by replying to the message and deleting it from your computer. Any views or opinions presented are solely those of the author vincent.dephily@REDACTED and do not necessarily represent those of the company. Although the company has taken reasonable precautions to ensure no viruses are present in this email, the company cannot accept responsibility for any loss or damage arising from the use of this email or attachments. From n.oxyde@REDACTED Fri Feb 20 13:46:15 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Fri, 20 Feb 2015 13:46:15 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> <52E7391D-2CCC-4C35-938B-91D752B83602@gmail.com> Message-ID: Le 20 f?vr. 2015 ? 12:44, Imants Cekusins a ?crit : >> Did it never occur to you that maybe your code is just badly organised? > > it may be. but this is another topic. let's not discuss it here, please. > > I do not impose this approach. some however may find it useful. It is very on topic, we are discussing a feature that you think would be useful based on how your current code is. You could wish for a pair of iron gloves while wielding a naked blade, or you could just wield a proper sword. From n.oxyde@REDACTED Fri Feb 20 13:47:18 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Fri, 20 Feb 2015 13:47:18 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <54E729EA.6040306@bestmx.net> References: <54E729EA.6040306@bestmx.net> Message-ID: Le 20 f?vr. 2015 ? 13:34, e@REDACTED a ?crit : > JSON is a subset of JS. No, it's a data-interchange format. Not all JSON is JS code. From ivan@REDACTED Fri Feb 20 13:50:22 2015 From: ivan@REDACTED (Ivan Uemlianin) Date: Fri, 20 Feb 2015 12:50:22 +0000 Subject: [erlang-questions] your first choice? In-Reply-To: References: <54E729EA.6040306@bestmx.net> Message-ID: <54E72D8E.4030705@llaisdy.com> In "Javascript: the good parts", Douglas Crockford claims JSON is a subset of javascript. On 20/02/2015 12:47, Anthony Ramine wrote: > Le 20 f?vr. 2015 ? 13:34, e@REDACTED a ?crit : > >> JSON is a subset of JS. > No, it's a data-interchange format. Not all JSON is JS code. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- ============================================================ Ivan A. Uemlianin PhD Llaisdy Speech Technology Research and Development ivan@REDACTED @llaisdy llaisdy.wordpress.com github.com/llaisdy www.linkedin.com/in/ivanuemlianin festina lente ============================================================ From radek@REDACTED Fri Feb 20 13:54:48 2015 From: radek@REDACTED (Radoslaw Gruchalski) Date: Fri, 20 Feb 2015 12:54:48 +0000 (UTC) Subject: [erlang-questions] your first choice? In-Reply-To: <54E72D8E.4030705@llaisdy.com> References: <54E729EA.6040306@bestmx.net> <54E72D8E.4030705@llaisdy.com> Message-ID: Json.org claims diffetent: JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. But practically, it is a subset. Sent from Outlook On Fri, Feb 20, 2015 at 4:50 AM -0800, "Ivan Uemlianin" wrote: In "Javascript: the good parts", Douglas Crockford claims JSON is a subset of javascript. On 20/02/2015 12:47, Anthony Ramine wrote: > Le 20 f?vr. 2015 ? 13:34, e@REDACTED a ?crit : > >> JSON is a subset of JS. > No, it's a data-interchange format. Not all JSON is JS code. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -- ============================================================ Ivan A. Uemlianin PhD Llaisdy Speech Technology Research and Development ivan@REDACTED @llaisdy llaisdy.wordpress.com github.com/llaisdy www.linkedin.com/in/ivanuemlianin festina lente ============================================================ _______________________________________________ erlang-questions mailing list erlang-questions@REDACTED http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From n.oxyde@REDACTED Fri Feb 20 13:57:30 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Fri, 20 Feb 2015 13:57:30 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <54E72D8E.4030705@llaisdy.com> References: <54E729EA.6040306@bestmx.net> <54E72D8E.4030705@llaisdy.com> Message-ID: Le 20 f?vr. 2015 ? 13:50, Ivan Uemlianin a ?crit : > In "Javascript: the good parts", Douglas Crockford claims JSON is a subset of javascript. Good old Bobby U+2028. From imantc@REDACTED Fri Feb 20 13:58:57 2015 From: imantc@REDACTED (Imants Cekusins) Date: Fri, 20 Feb 2015 13:58:57 +0100 Subject: [erlang-questions] Process scope variable In-Reply-To: References: <2355659.CI61d1bmZG@changa> <54E5DD73.5070804@ninenines.eu> <54E5DFFB.7000609@ninenines.eu> <20150219141746.GC4955@ferdair.local> <46A47FEE-42C3-4805-9C74-3A530CC728D3@cs.otago.ac.nz> <52E7391D-2CCC-4C35-938B-91D752B83602@gmail.com> Message-ID: Anthony, thank you very much for your readiness to help. there is time to learn and there is time to deliver. it's like in school: lessons are followed by a quiz. For me it's quiz time now. It's not the right time to change the way I think or program. whatever I learnt so far will be reflected in the mark (grade) received. This will be the mark I deserve. wish me good luck. From jesper.louis.andersen@REDACTED Fri Feb 20 14:09:28 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 20 Feb 2015 14:09:28 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: On Mon, Feb 16, 2015 at 6:06 AM, Peter J Etheridge wrote: > yaws or mochiweb? > mnesia or mongoDB? > chicago boss or ...? > XML or JSon? > intellij idea or eclipse? > and before i buy a server, Win or Linux or ...? > If I had freedom of choice and problem notwithstanding: Webmachine or Cowboy for the web server. Proper RESTful approaches are too good to leave up. Postgresql for smaller databases (up to 5-10 terabytes in size roughly). After that, it depends on the CAP theorem and if you lean CP or AP. For the latter, Riak. Never pick a "framework", since they always limit you in the long run. If I *had* to, I would research nitrogen or n2o. Transit for data interchange, naturally ( https://github.com/isaiah/transit-erlang) acme(1) or sam(1) as the editor ( http://en.wikipedia.org/wiki/Acme_%28text_editor%29 , http://en.wikipedia.org/wiki/Sam_%28text_editor%29) YMMV a bit here :) FreeBSD on the server, preferably. If not, Illumos/SmartOS. Then OpenBSD, then Linux. Windows is not for serious work, but a toy for computer gaming. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Fri Feb 20 14:37:15 2015 From: davidnwelton@REDACTED (David Welton) Date: Fri, 20 Feb 2015 14:37:15 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: > Never pick a "framework", since they always limit you in the long run. If I > *had* to, I would research nitrogen or n2o. "In the long run, we are all dead." - John Maynard Keynes Normally, jlouis is a source of great advice and tons of wisdom about Erlang and programming in general, but I will respectfully disagree in this case. First of all, let me say that it does depend on what you're out to accomplish and in what time frame. If you just want to get *something* up and running, a framework can be a wonderful starting point. For many startups, for instance, the important thing is finding product-market fit, and the faster you have something in front of people, the faster you can start trying to discern whether it's something they'll buy. If you take a long time building something carefully by hand, piece by piece, carefully crafted and thought through, you may run through all your time/money and discover that what you built was not what people actually wanted. It's basically a "worse is better" situation. Certainly a framework might be a hindrance at some point in the future, but if you get to that point, you probably have some money and resources to rectify the situation. Other startups are more about technological, rather than market risk - can the thing be built at all? If it can, there's surely a market for it. The canonical example of this is a "cure for cancer". In that case, perhaps more up-front design is needed! In some ways, a framework is just a bunch of components that work together that anyone approaching a similar problem will end up putting together in a similar way in any case. For instance, with a database, you'll very likely want something like poolboy and something like fuse involved, sooner or later. Not having to wire that up yourself is simply a time saver. And; once again, if it's just a learning project, you can do whatever you feel maximizes your learning experience. That sort of thing has different goals than a project with business requirements. -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From e@REDACTED Fri Feb 20 14:39:05 2015 From: e@REDACTED (e@REDACTED) Date: Fri, 20 Feb 2015 14:39:05 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: <54E738F9.9040007@bestmx.net> >> yaws or mochiweb? >> mnesia or mongoDB? >> chicago boss or ...? >> XML or JSon? >> intellij idea or eclipse? >> and before i buy a server, Win or Linux or ...? >> > > If I had freedom of choice and problem notwithstanding: > > Webmachine or Cowboy for the web server. Proper RESTful approaches are too > good to leave up. if it is "Webmachine or Cowboy?" then, no doubt, Cowboy. i was using both, and it is clear to me that webmachine loses every comparison. > Postgresql for smaller databases (up to 5-10 terabytes in size roughly). > After that, it depends on the CAP theorem and if you lean CP or AP. For the > latter, Riak. Postgresql is an application server in its own right, Erlang renders Postgres useless -- Postgres renders Erlang useless. Doing Erlang+Postgres is like doing the same job twice. > Never pick a "framework", since they always limit you in the long run. I couldn't agree more!!! there is no room for a "frameworks" in a well designed system, using appropriate tools. From zxq9@REDACTED Fri Feb 20 14:44:45 2015 From: zxq9@REDACTED (zxq9) Date: Fri, 20 Feb 2015 22:44:45 +0900 Subject: [erlang-questions] your first choice? In-Reply-To: <54E72D8E.4030705@llaisdy.com> References: <54E72D8E.4030705@llaisdy.com> Message-ID: <2560406.gaRp0xbQ6r@changa> On 2015?2?20? ??? 12:50:22 Ivan Uemlianin wrote: > In "Javascript: the good parts", Douglas Crockford claims JSON is a > subset of javascript. > > On 20/02/2015 12:47, Anthony Ramine wrote: > > Le 20 f?vr. 2015 ? 13:34, e@REDACTED a ?crit : > >> JSON is a subset of JS. > > > > No, it's a data-interchange format. Not all JSON is JS code. Crockford claims a lot of interesting things about JS from time to time. None of it has changed my desire to avoid the language as much as possible. One can do truly brilliant things in truly dumb languages -- there are mountains of brilliant COBOL where, sadly, the exercise of brilliance was primarily in the effort to overcome the tools used instead of the problem at hand. In any case, JSON is a subset of JS in the same way Python dictionary notation is a subset of Python. It is more meaningful to remember that YAML is a superset of JSON, as this clarifies the intent of JSON for anyone uncertain of it. From e@REDACTED Fri Feb 20 14:48:34 2015 From: e@REDACTED (e@REDACTED) Date: Fri, 20 Feb 2015 14:48:34 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <2560406.gaRp0xbQ6r@changa> References: <54E72D8E.4030705@llaisdy.com> <2560406.gaRp0xbQ6r@changa> Message-ID: <54E73B32.7030509@bestmx.net> > One can > do truly brilliant things in truly dumb languages -- there are mountains of > brilliant COBOL where, sadly, the exercise of brilliance was primarily in the > effort to overcome the tools used instead of the problem at hand. i feel pretty much the same "in" every "language" except for Erlang :) From roberto@REDACTED Fri Feb 20 15:11:20 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Fri, 20 Feb 2015 15:11:20 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> Message-ID: Dear List, Given the amount of answers I got in this post, I want to follow up and give some additional information. After struggling for quite a while, I just did a comparison between using SSL connections vs standard TCP connections. The results are quite impressive. This is the diagram of memory evolution for a system under load, with SSL: https://cldup.com/cNOc8hS004-2000x2000.png This is the same system, but without SSL: https://cldup.com/sx3RrdMR8o-3000x3000.png You can clearly see that using standard TCP connections the system is extremely stable. Using SSL connections, on the other hand, results in RAM memory having very erratic behavior that ends up blowing up the node. Not sure what to do with this information, except that I'm going to use a SSL termination (HAProxy or ELB) and have my Erlang node run without SSL. If anyone is curious just ping me. Best, r. On Wed, Jan 28, 2015 at 8:09 PM, Roberto Ostinelli < roberto.ostinelli@REDACTED> wrote: > That's a valid point, and I can clarify. > > During the first phase, all the long lived connections are made. During > the second phase, newly-created short lived connections send messages to > the long lived ones. > > The long lived connection are all connected when the first memory increase > phase ends, which is when the short-lived connections start sending > messages. > > What is unclear to me is why the second memory increase phase happens > quite some time after these short lived processes have started sending > messages. > > > > On 28/gen/2015, at 20:02, Anton Lebedevich wrote: > > > > The graph looks really weird for me assuming that the load applied to > > the system is stable. Why does it go down for a short time and then > > jumps higher than it was? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Fri Feb 20 15:28:14 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 20 Feb 2015 15:28:14 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: On Fri, Feb 20, 2015 at 2:37 PM, David Welton wrote: > First of all, let me say that it does depend on what you're out to > accomplish and in what time frame. > Indeed, the great lure of frameworks are they make prior choices for you under the pretense the choices are correct and useful for your problem. By making the decisions quickly, you get a minimum viable product faster and have a shorter time to market. In turn, you gain the de-facto monopoly anyone hopes to get. The same can be said about astrology. If the constellations and planetary bodies are just right, you will bathe in gold. If they are ever so slightly off, you will bathe in lead. And nobody told the astrologers about Styx or Cerberus, so they can't by definition have gotten the bodies right in their charts. The crux of my argument is based upon the prior choice of features. First, you need prior knowledge of the framework itself. You need to know its performance model: what is fast and what is slow. You need to know the internal architecture. Otherwise, you are probably worse off than just writing the code. A network effect is apparent: the more you work in a framework, the more accumulated knowledge you have and the faster can you build new stuff. The 10th Rails project is easier to write than the 1st. Second, your problem has to match the frameworks framing, in the sense that the problem space you are facing matches somewhat well with that of the framework. As an example, it is hard to take the MVC pattern and fit into an Event Sourcing/CQRS model. Of course you could learn a new framework, but this requires prior knowledge as well. So you need prior knowledge of what problem you need to solve, or it is square pegs through rounds holes all the way down. My claim is that any interesting problem has high risk. In turn, any interesting problem is unknown by definition. Hence, you don't know a priori if your framework fits the problem in any way, and learning one is more or less hit-or-miss. You may get a lucky strike, but it was definitely not by considerate aiming of the weapon. This is why I prefer tools to frameworks. For a risky problem, the freedom of picking tools for the job dwarf the advantage of using a framework. I thrive much better by gluing my own solution together. YMMV of course, depending on the task at hand and your prior knowledge. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jesper.louis.andersen@REDACTED Fri Feb 20 15:39:43 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Fri, 20 Feb 2015 15:39:43 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <54E738F9.9040007@bestmx.net> References: <54E738F9.9040007@bestmx.net> Message-ID: On Fri, Feb 20, 2015 at 2:39 PM, e@REDACTED wrote: > Postgresql is an application server in its own right, > Erlang renders Postgres useless -- Postgres renders Erlang useless. > Doing Erlang+Postgres is like doing the same job twice. > No tool renders the other useless, if you happen to know its major strengths and weaknesses[0]. Mnesia is best-in-class if you have lots of K/V lookups of data with sub-?s latency. But if most of your queries are on deep JSON structures in columns, or you have many complicated joins of data, then Postgres is a far better tool. In addition, pg is very good at solving the persistence question and keeping your data safe on disk. Furthermore, pg is way better at date-handling than Erlang, so I often outsouce date-handling code into pg. Another point is if you can't render all your data in memory all the time. Catie McCaffrey et.al, ran the Halo4 servers on Azure in a .NET framework named Orleans. This Actor framework kept state in memory and was strictly AP for most operations. Whenever money was involved however, an SQL Server database was used to isolate and "linearize" conflicts. And I think I can find many examples where different systems provide different guarantees. The gist of pgsql is to provide ACID easily into your platform, so you can avoid implementing that for certain subparts, while keeping the rest of the system asynchronous and fast. Exactly like Catie and Co. did. [0] Of course, there are exceptions. MongoDB and MySQL are almost completely useless because their primary strengths are supplanted by other tools nowadays. They mostly exist to handle historical systems, much like COBOL. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From garry@REDACTED Fri Feb 20 16:03:43 2015 From: garry@REDACTED (Garry Hodgson) Date: Fri, 20 Feb 2015 10:03:43 -0500 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: <54E74CCF.20104@research.att.com> On 02/20/2015 08:09 AM, Jesper Louis Andersen wrote: > acme(1) or sam(1) as the editor > (http://en.wikipedia.org/wiki/Acme_%28text_editor%29 , > http://en.wikipedia.org/wiki/Sam_%28text_editor%29) YMMV a bit here :) > sam! good to know that at least someone else remembers sam. the lack of it when we moved from blit/5620 to sun 3/60 years ago is what started my habit of implementing my own text editors over the years. been a half dozen or sp of them since then, as i migrated through various platforms and windowing systems. -- Garry Hodgson AT&T Chief Security Office (CSO) "This e-mail and any files transmitted with it are AT&T property, are confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not one of the named recipient(s) or otherwise have reason to believe that you have received this message in error, please notify the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited." From e@REDACTED Fri Feb 20 16:06:48 2015 From: e@REDACTED (e@REDACTED) Date: Fri, 20 Feb 2015 16:06:48 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: <54E738F9.9040007@bestmx.net> Message-ID: <54E74D88.1030300@bestmx.net> On 02/20/2015 03:39 PM, Jesper Louis Andersen wrote: > On Fri, Feb 20, 2015 at 2:39 PM, e@REDACTED wrote: > >> Postgresql is an application server in its own right, >> Erlang renders Postgres useless -- Postgres renders Erlang useless. >> Doing Erlang+Postgres is like doing the same job twice. >> > > No tool renders the other useless, if you happen to know its major > strengths and weaknesses[0]. please, allow me to rephrase my point: if two tools compete for the same "job" they are mutually exclusive. in case of Erlang+Postgres: Postgres provides you very nice application server, while Erlang provides you interesting means of data storage. either one has its advantages and its drawbacks. while the combination of them provides you all the drawbacks of both. > Furthermore, pg is way better > at date-handling than Erlang, so I often outsource date-handling code into > pg. Exactly what i do all the time! and i have never met anyone to agree with me on the point :) > Whenever money was involved however, an SQL Server > database was used to isolate and "linearize" conflicts. totally agree. this is why i delegate all "password handling" and "money jobs" to pg. to the extent of eliminating any scripting between pg and nginx. > The gist of pgsql is to provide ACID easily into your platform, so you can > avoid implementing that for certain subparts, while keeping the rest of the > system asynchronous and fast. Exactly like Catie and Co. did. it sounds logical, but i can not imagine how is it practically possible to keep these two subsystems *so* isolated (independent)... > [0] Of course, there are exceptions. MongoDB and MySQL are almost > completely useless because their primary strengths are supplanted by other > tools nowadays. They mostly exist to handle historical systems, much like > COBOL. there are very few thinkers like you in this world. you know? From davidnwelton@REDACTED Fri Feb 20 16:49:29 2015 From: davidnwelton@REDACTED (David Welton) Date: Fri, 20 Feb 2015 16:49:29 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: > Indeed, the great lure of frameworks are they make prior choices for you > under the pretense the choices are correct and useful for your problem. By > making the decisions quickly, you get a minimum viable product faster and > have a shorter time to market. In turn, you gain the de-facto monopoly > anyone hopes to get. It doesn't even need to be about a monopoly, but about just getting something out there and figuring out if there's a viable business there at all. > So you need prior knowledge of what problem you need to solve, or it is > square pegs through rounds holes all the way down. You don't necessarily get that, so sometimes it's best to get up and running quickly and start learning. Maybe out of 5 features you had in mind, the customers love 1 and buy your product for it, and don't care much about the other 4. It's difficult to know that a priori. > The crux of my argument is based upon the prior choice of features. First, you need prior knowledge of the framework itself. You need to know its performance model: what is fast and what is slow. You need to know the internal architecture. Otherwise, you are probably worse off than just writing the code. A network effect is apparent: the more you work in a framework, the more accumulated knowledge you have and the faster can you build new stuff. The 10th Rails project is easier to write than the 1st. Second, your problem has to match the frameworks framing, in the sense that the problem space you are facing matches somewhat well with that of the framework. As an example, it is hard to take the MVC pattern and fit into an Event Sourcing/CQRS model. Of course you could learn a new framework, but this requires prior knowledge as well. You actually may not need to know the framework that intimately. There are a whole slew of problems that you could solve with pretty much any old thing out there, given how bad existing solutions are. > My claim is that any interesting problem has high risk. For a business, at least, in a lot of cases the risk is 'market' risk, though: http://ecorner.stanford.edu/authorMaterialInfo.html?mid=2325 - which may not correspond to an 'interesting problem' in terms of technology at all. You could use PHP and MongoDB and whatever other icky tech, and it'd probably work out if you get that one key thing that makes people want to buy your product. As a well-known example from the world of bootstrapped businesses: http://www.bingocardcreator.com/ which has been amply discussed online. He originally made it as a downloadable Java program, then redid it as a Rails web application. Realistically, I'm sure he could have used pretty much any old thing he knew well enough: the 'interesting' part of BCC is not the technology, but the marketing he put into it. > In turn, any > interesting problem is unknown by definition. Hence, you don't know a priori > if your framework fits the problem in any way, and learning one is more or > less hit-or-miss. You may get a lucky strike, but it was definitely not by > considerate aiming of the weapon. >From that point of view, even tools carry risks. Twitter started with Ruby on Rails, which, much as it's nice for some things, is manifestly the wrong thing to be using for what they do. Postgres, which I happen to like a lot, is the wrong thing for some problems. Erlang itself is the wrong tool if you need every last bit of performance from your CPU to crunch numbers. And yet Erlang is still probably not a bad starting place if you don't know that ahead of time: you could use it to manage the number crunching code, and you're likely to get some kind of system up and running a bit quicker than if you hand code it in C. > This is why I prefer tools to frameworks. For a risky problem, the freedom > of picking tools for the job dwarf the advantage of using a framework. I > thrive much better by gluing my own solution together. Backing away from the abstractions, the guy asked about creating a web application. That's a known problem and involves some of the following: * A web server. * Something to connect it to to run code dynamically, rather than simply serve static web pages. * Some kind of templating system. * Some kind of data store. Having a starting place that does all of that is a good jumping off point for working on whatever it is that is actually interesting to customers. Having something to start from also means you will discover sooner, rather than later, if it's not adequate for what you need, and give you firmer ideas about what you actually do need. This is also an information asymmetry problem: people who are just getting started are the ones least able to evaluate a bunch of disparate tools, so giving them something that at least *works* out of the box is going to save them time and give them a leg up to a point where they are more comfortable, understand more things, and are able to start making any decisions about replacing bits and pieces or doing things differently. -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From e@REDACTED Fri Feb 20 17:06:07 2015 From: e@REDACTED (e@REDACTED) Date: Fri, 20 Feb 2015 17:06:07 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: <54E75B6F.8040807@bestmx.net> >> The crux of my argument is based upon the prior choice of features. First, you need prior knowledge of the framework itself. You need to know its performance model: what is fast and what is slow. You need to know the internal architecture. Otherwise, you are probably worse off than just writing the code. A network effect is apparent: the more you work in a framework, the more accumulated knowledge you have and the faster can you build new stuff. The 10th Rails project is easier to write than the 1st. Second, your problem has to match the frameworks framing, in the sense that the problem space you are facing matches somewhat well with that of the framework. As an example, it is hard to take the MVC pattern and fit into an Event Sourcing/CQRS model. Of course you could learn a new framework, but this requires prior knowledge as well. > > You actually may not need to know the framework that intimately. This is a common problem of all "frameworks": they all claim "no need to know them intimately" and they all in fact require that knowledge. unlike many other "raw" tools. frameworks massively fail at the task of abstraction -- knowing "specification" is never enough for a "framework". From e@REDACTED Fri Feb 20 17:11:29 2015 From: e@REDACTED (e@REDACTED) Date: Fri, 20 Feb 2015 17:11:29 +0100 Subject: [erlang-questions] beta-testers needed Message-ID: <54E75CB1.8040104@bestmx.net> Hi, all. i need few volunteers to help me test my game-server (abstract board game). in order to keep the list clean, please respond privately. how is it related to erlang? it is written in erlang. From radek@REDACTED Fri Feb 20 17:20:43 2015 From: radek@REDACTED (Rad Gruchalski) Date: Fri, 20 Feb 2015 17:20:43 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <54E738F9.9040007@bestmx.net> References: <54E738F9.9040007@bestmx.net> Message-ID: <55B359CAB5CF49C0B468B2E7C8BF030C@gruchalski.com> On Friday, 20 February 2015 at 14:39, e@REDACTED wrote: > > > yaws or mochiweb? > > > mnesia or mongoDB? > > > chicago boss or ...? > > > XML or JSon? > > > intellij idea or eclipse? > > > and before i buy a server, Win or Linux or ...? > > > > > > > > > If I had freedom of choice and problem notwithstanding: > > > > Webmachine or Cowboy for the web server. Proper RESTful approaches are too > > good to leave up. > > > > > if it is "Webmachine or Cowboy?" > then, no doubt, Cowboy. > > i was using both, and it is clear to me that webmachine loses every > comparison. > > > > Postgresql for smaller databases (up to 5-10 terabytes in size roughly). > > After that, it depends on the CAP theorem and if you lean CP or AP. For the > > latter, Riak. > > > > > Postgresql is an application server in its own right, > Erlang renders Postgres useless -- Postgres renders Erlang useless. > Doing Erlang+Postgres is like doing the same job twice. > > Care explaining why do you consider postgres ?an application server?? > > Never pick a "framework", since they always limit you in the long run. > > > I couldn't agree more!!! > there is no room for a "frameworks" in a well designed system, using > appropriate tools. > > Really? Do you write everything from scratch for every new project? Your own grid system? Your own reactive css? Your own, I don?t know, deployment tools? Do you use OTP? I think there?s a common misconception between ?a framework? and ?a library?. -------------- next part -------------- An HTML attachment was scrubbed... URL: From radek@REDACTED Fri Feb 20 17:27:53 2015 From: radek@REDACTED (Rad Gruchalski) Date: Fri, 20 Feb 2015 17:27:53 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <54E75B6F.8040807@bestmx.net> References: <54E75B6F.8040807@bestmx.net> Message-ID: <029F3FB83DEB40C2BDCDC038BADC53FF@gruchalski.com> On Friday, 20 February 2015 at 17:06, e@REDACTED wrote: > frameworks massively fail at the task of abstraction -- knowing > "specification" is never enough for a "framework". > Knowing specification is one thing, rejecting some common solutions, sometimes worked out for years of repetitive problem solving, is another thing. I think you are possibly a bit extreme in your judgement. > > _______________________________________________ > 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 ivan@REDACTED Fri Feb 20 17:31:44 2015 From: ivan@REDACTED (Ivan Uemlianin) Date: Fri, 20 Feb 2015 16:31:44 +0000 Subject: [erlang-questions] your first choice? In-Reply-To: <54E74D88.1030300@bestmx.net> References: <54E738F9.9040007@bestmx.net> <54E74D88.1030300@bestmx.net> Message-ID: <54E76170.2050800@llaisdy.com> On 20/02/2015 15:06, e@REDACTED wrote: > ... in case of Erlang+Postgres: Postgres provides you very nice > application server, ... This is very interesting. Are you talking about ngx_postgres? Best wishes Ivan -- ============================================================ Ivan A. Uemlianin PhD Llaisdy Speech Technology Research and Development ivan@REDACTED @llaisdy llaisdy.wordpress.com github.com/llaisdy www.linkedin.com/in/ivanuemlianin festina lente ============================================================ From e@REDACTED Fri Feb 20 17:34:21 2015 From: e@REDACTED (e@REDACTED) Date: Fri, 20 Feb 2015 17:34:21 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <54E76170.2050800@llaisdy.com> References: <54E738F9.9040007@bestmx.net> <54E74D88.1030300@bestmx.net> <54E76170.2050800@llaisdy.com> Message-ID: <54E7620D.3090609@bestmx.net> On 02/20/2015 05:31 PM, Ivan Uemlianin wrote: > On 20/02/2015 15:06, e@REDACTED wrote: >> ... in case of Erlang+Postgres: Postgres provides you very nice >> application server, ... > This is very interesting. Are you talking about ngx_postgres? yes. i have some papers on the topic and a presentation if you wish. and one unfinished tutorial. From e@REDACTED Fri Feb 20 17:39:52 2015 From: e@REDACTED (e@REDACTED) Date: Fri, 20 Feb 2015 17:39:52 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <029F3FB83DEB40C2BDCDC038BADC53FF@gruchalski.com> References: <54E75B6F.8040807@bestmx.net> <029F3FB83DEB40C2BDCDC038BADC53FF@gruchalski.com> Message-ID: <54E76358.7030507@bestmx.net> On 02/20/2015 05:27 PM, Rad Gruchalski wrote: > On Friday, 20 February 2015 at 17:06, e@REDACTED wrote: >> frameworks massively fail at the task of abstraction -- knowing >> "specification" is never enough for a "framework". >> > Knowing specification is one thing, rejecting some common solutions, sometimes worked out for years of repetitive problem solving, is another thing. I think you are possibly a bit extreme in your judgement. i can not recognize an objection to my statement. From radek@REDACTED Fri Feb 20 17:46:39 2015 From: radek@REDACTED (Rad Gruchalski) Date: Fri, 20 Feb 2015 17:46:39 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <54E76358.7030507@bestmx.net> References: <54E75B6F.8040807@bestmx.net> <029F3FB83DEB40C2BDCDC038BADC53FF@gruchalski.com> <54E76358.7030507@bestmx.net> Message-ID: On Friday, 20 February 2015 at 17:39, e@REDACTED wrote: > > > On 02/20/2015 05:27 PM, Rad Gruchalski wrote: > > On Friday, 20 February 2015 at 17:06, e@REDACTED (mailto:e@REDACTED) wrote: > > > frameworks massively fail at the task of abstraction -- knowing > > > "specification" is never enough for a "framework". > > > > > > > Knowing specification is one thing, rejecting some common solutions, sometimes worked out for years of repetitive problem solving, is another thing. I think you are possibly a bit extreme in your judgement. > > > > > i can not recognize an objection to my statement. There was none. Just a hint that ?a framework? (or a library) is not always claiming to be ?the only solution, otherwise there be dragons?. Some of them encapsulate some knowledge, is it wise rejecting on a basis ?it?s a framework"? Sometimes a framework is a great learning source, for example - how to handle a protocol correctly. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ryankbrown@REDACTED Fri Feb 20 17:48:06 2015 From: ryankbrown@REDACTED (Ryan Brown) Date: Fri, 20 Feb 2015 09:48:06 -0700 Subject: [erlang-questions] Problem with legacy code when upgrading to R16B03 In-Reply-To: References: Message-ID: Ok, I cannot make it break now. I'm perplexed as I had several engineers look at it and test it. Argh! Thank you for the educational comments. Whether on not this was a red herring, I have learned a lot and I very much appreciate it. Best regards. On Thu, Feb 19, 2015 at 3:17 PM, Felix Gallo wrote: > I also would find that surprising, and indeed your code seems to crash on > 15B01 as well, at least with my inputs. Is it possible that there is > something else that happened along the way which is causing different > inputs to be presented to the function, or some circumstance which is > causing that branch to get triggered where it never has before? > > On Thu, Feb 19, 2015 at 1:11 PM, Ryan Brown wrote: > >> Thank you for the excellent clarification Felix. This code was written >> five years ago and we are just trying to update the version of Erlang it's >> running on. Everything seems to run fine on R15B (has been in production >> w/o issue for five years). >> >> So, while I was able to refactor the code to work, I suppose I am still >> scratching my head as to why this would have changed between R15 and R16. >> I've read the release readme and don't see anything obvious. >> >> Best regards, >> >> Ryan >> >> On Thu, Feb 19, 2015 at 1:33 PM, Felix Gallo >> wrote: >> >>> A constructive note: it's hard for readers (e.g. me) to reason about >>> what's happening without a full, minimal failing test case, including the >>> data you're passing in. Just the act of creating a minimal failing test >>> case is also a great debugging step that often illuminates/solves the >>> problem (along the lines of 'rubber duck debugging' ( >>> http://en.wikipedia.org/wiki/Rubber_duck_debugging)). For example, >>> maybe you're passing in the wrong kind of data; that is very common and is >>> frequently exposed when you type it in a second time and look at it. >>> >>> For the purposes of this discussion I created a test() function: >>> >>> test() -> >>> X = <<1:128>>, >>> Y = <<1:53>>, >>> Z = <<1:1>>, >>> pad_binary_128(X), >>> pad_binary_128(Y), >>> pad_binary_128(Z). >>> >>> and then I run it like so: >>> >>> Eshell V6.1 (abort with ^G) >>> 1> c(a),l(a),a:test(). >>> Line 100 >>> Line 97 >>> ** exception error: bad argument >>> in function a:pad_binary_128/1 (a.erl, line 12) >>> in call from a:test/0 (a.erl, line 22) >>> >>> and see your error when I am trying to use a 53 bit bitstring. >>> >>> In this particular scenario that matches the clause: >>> >>> pad_binary_128(Data) when bit_size(Data) < 128 -> >>> io:format("Line ~p~n", [97]), >>> pad_binary_128(<>); >>> >>> this appears to me be an excessively clever attempt to right-pad the >>> binary with zeroes. In particular, the original author thought >>> <> would construct a binary with one zero to the right, >>> and then recursion would continue until the string was 128 bits long. >>> >>> As a debug step, let's break out the construction attempt from the >>> function call: >>> >>> New = <>; >>> pad_binary_128(New); >>> >>> now we get the error at the constructor. How exciting! >>> >>> So we turn to the documentation ( >>> http://www.erlang.org/doc/programming_examples/bit_syntax.html) and see >>> that you will get badarg errors when you attempt to construct a binary that >>> has an unaligned byte boundary -- e.g., anything not divisible by 8. In >>> this case, Data/binary could be attempting to convert an unaligned >>> bitstring into a binary, which can't be done. >>> >>> In order to fix the problem in a short term way, you could change that >>> to <> and it would run fine. But it also recurses for >>> every single bit of padding, which is a little, ah, corkbrained. >>> >>> Better would be to refactor this code a little so it's a bit more >>> sensible. I am by no means an erlang grandmaster but here's how I >>> personally would do it. The specs pass dialyzer and there's a brief test >>> suite that hits some of the high notes. >>> >>> https://github.com/Cloven/bitpad128/blob/master/bit_example.erl >>> >>> F. >>> >>> On Thu, Feb 19, 2015 at 11:02 AM, Ryan Brown >>> wrote: >>> >>>> Thank you Felix. I did get that to work standalone. It appears that >>>> there is something in the pad_binary method that I have not been able to >>>> track-down. >>>> >>>> In a crude attempt to trace the issue down, I added a bunch of >>>> io:formats and ran in the shell. >>>> >>>> pad_binary_128(Data) when bit_size(Data) > 128 -> >>>> io:format("Line ~p~n", [89]), >>>> {Kept, _Lost} = split_binary(Data, size(Data) - 1), >>>> io:format("Line ~p~n", [94]), >>>> pad_binary_128(Kept); >>>> pad_binary_128(Data) when bit_size(Data) < 128 -> >>>> io:format("Line ~p~n", [97]), >>>> pad_binary_128(<>); >>>> pad_binary_128(Data) -> >>>> io:format("Line ~p~n", [100]), >>>> Data. >>>> >>>> This is the output I get: >>>> >>>> Line 97 >>>> ** exception error: bad argument >>>> in function omac1:pad_binary_128/1 (src/omac1.erl, line 97) >>>> in call from omac1:cmac_aes_cbc_128/6 (src/omac1.erl, line 78) >>>> >>>> So, it almost seems like there may be a difference in the way that >>>> bit_size/1 is handled in R1603. However, I do not see anything that >>>> stands-out to me in the docs. >>>> >>>> >>>> http://erldocs.com/R15B01/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 >>>> >>>> http://erldocs.com/R16B03/erts/erlang.html?i=0&search=erlang:bit#bit_size/1 >>>> >>>> Thanks in advance. >>>> >>>> Best, >>>> >>>> Ryan >>>> >>>> On Tue, Feb 17, 2015 at 5:21 PM, Felix Gallo >>>> wrote: >>>> >>>>> I made your same changes to the module, and also added the following >>>>> function to the module: >>>>> >>>>> test() -> >>>>> Key = <<1:128>>, >>>>> Data = <<1:128>>, >>>>> generate_tag_aes_cbc_128(Key, Data). >>>>> >>>>> and when run in a shell: >>>>> >>>>> Eshell V6.1 (abort with ^G) >>>>> 1> c(omac1),l(omac1),omac1:test(). >>>>> <<173,219,62,66,7,255,149,96,196,74,41,116,238,229,211,35>> >>>>> >>>>> this appears to work (at least, it doesn't crash with badarg. I don't >>>>> know whether the data is correct). Are you sure your aes key is 128, 192, >>>>> or 256 bits long? It's possible the crypto module is throwing badarg when >>>>> it detects an improper length key. >>>>> >>>>> On Tue, Feb 17, 2015 at 3:27 PM, Ryan Brown >>>>> wrote: >>>>> >>>>>> Thank you Felix. It looks like the aes_cbc_128_encrypt method is gone >>>>>> so I changed all to use crypto:block_encrypt(aes_cbc128, Key, IV, >>>>>> ToBeEncrypted) >>>>>> >>>>>> But alas, I'm still seeing the same error. >>>>>> >>>>>> On Tue, Feb 17, 2015 at 3:10 PM, Felix Gallo >>>>>> wrote: >>>>>> >>>>>>> I'm not super familiar with the crypto library, but it looks like >>>>>>> its function signatures changed significantly between 15B01 and 16B03. In >>>>>>> particular, it appears that some of the functions you are calling are no >>>>>>> longer in the library, and have been replaced with equivalents. >>>>>>> >>>>>>> I suggest opening >>>>>>> >>>>>>> http://erldocs.com/R15B01/crypto/crypto.html >>>>>>> >>>>>>> and >>>>>>> >>>>>>> http://erldocs.com/R16B03/crypto/crypto.html >>>>>>> >>>>>>> and seeing if you can figure out where the changes occurred. I >>>>>>> suspect those are the cause of your badargs. >>>>>>> >>>>>>> F. >>>>>>> >>>>>>> On Tue, Feb 17, 2015 at 1:55 PM, Ryan Brown >>>>>>> wrote: >>>>>>> >>>>>>>> Hello all, >>>>>>>> >>>>>>>> I am in the process of upgrading a legacy application from R15B01 >>>>>>>> to R16B03 in order to get SHA 384 support. However, I am getting an error >>>>>>>> creating my CMAC from the library located here: >>>>>>>> >>>>>>>> https://github.com/PearsonEducation/subpub/blob/master/src/omac1.erl >>>>>>>> >>>>>>>> For the life of me I cannot find the root cause. I am just >>>>>>>> receiving a badarg error pointing to line 74. >>>>>>>> >>>>>>>> Any guidance would be greatly appreciated. >>>>>>>> >>>>>>>> Thank you. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> erlang-questions mailing list >>>>>>>> erlang-questions@REDACTED >>>>>>>> http://erlang.org/mailman/listinfo/erlang-questions >>>>>>>> >>>>>>>> >>>>>>> >>>>>> >>>>> >>>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Fri Feb 20 18:06:39 2015 From: davidnwelton@REDACTED (David Welton) Date: Fri, 20 Feb 2015 18:06:39 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: <54E75B6F.8040807@bestmx.net> References: <54E75B6F.8040807@bestmx.net> Message-ID: >> You actually may not need to know the framework that intimately. > > > This is a common problem of all "frameworks": > they all claim "no need to know them intimately" and they all in fact > require that knowledge. I don't know; I built a small business myself with Ruby on Rails and have never needed to dive into its internals or hack on it, or subvert it. It's done rather nicely, actually. I know plenty of other people in the same boat. There are certainly situations in which what you say is true, but it is not an "all" or "none" rule. You can do lots without having to ever bother with really thorough knowledge of how some things are put together. -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From g@REDACTED Fri Feb 20 18:11:10 2015 From: g@REDACTED (Garrett Smith) Date: Fri, 20 Feb 2015 11:11:10 -0600 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> Message-ID: On Fri, Feb 20, 2015 at 8:11 AM, Roberto Ostinelli wrote: > Dear List, > Given the amount of answers I got in this post, I want to follow up and give > some additional information. > > After struggling for quite a while, I just did a comparison between using > SSL connections vs standard TCP connections. > The results are quite impressive. > > This is the diagram of memory evolution for a system under load, with SSL: > https://cldup.com/cNOc8hS004-2000x2000.png > > This is the same system, but without SSL: > https://cldup.com/sx3RrdMR8o-3000x3000.png > > You can clearly see that using standard TCP connections the system is > extremely stable. > Using SSL connections, on the other hand, results in RAM memory having very > erratic behavior that ends up blowing up the node. > > Not sure what to do with this information, except that I'm going to use a > SSL termination (HAProxy or ELB) and have my Erlang node run without SSL. This is my standard practice now - motivated by a number of production issues. Fronting Erlang with an SSL proxy is completely trivial and makes the pain go away. I guess it'd be nice if Erlang kept up with the Nginxes and HAProxies, but not a must have. From mmartin4242@REDACTED Fri Feb 20 18:47:03 2015 From: mmartin4242@REDACTED (Michael Martin) Date: Fri, 20 Feb 2015 12:47:03 -0500 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: @David: I agree with all of your points. Having been in this business for a long time, time-to-market is always of high priority, if you are in the game to make money. So, getting something up and running quickly, something that can be shown to potential customers, or better yet, VCs, is very important. I recently worked on a project that was done entirely in python/wsgi mainly because of time to market. That product would be better done in Erlang/OTP, but there was simply no time for the development team to take on that learning curve. @Peter: I am in the same position you are. I desperately want to become proficient with Erlang, and have taken on a project to develop a web app, the particulars of which I am pretty familiar - I won't have a lot to learn about the "interesting problem", as I've been through all that before. So, my focus is on how to implement that in Erlang. I've only been working on this for a couple of months, and I don't really have a lot of time to spend on it due to the fact that I have a day job that keeps me too busy. Here's where I stand after going through the same process of discovery that you are going through. YMMV, of course: I originally thought about doing this as a Haskell/Yesod project, but got bogged down in Haskell's infamous "dependency hell" issue. Yesod claims to be able to handle 100k+ concurrent web connections, which is why I first thought about going that way. After getting frustrated with Haskell, I fell back to Erlang, which I already know, somewhat. I don't know enough to be hired to do Erlang for a paycheck yet, but I'm definitely trying to get to that level. At the same time, I discovered Elixir, which runs on the Erlang vm, and spent a couple of weeks looking at that. My impression of Elixir is that it looks promising, but is still rather immature, and will need some time to become industrial strength. So, once again, back to Erlang. What I now have is the beginnings of a web server, written in Erlang, using gar1t's e2 framework (makes OTP easier) and his modlib (makes working with erlang's httpd module way easier). Here is my current tools/frameworks list: Language: Erlang R17 Frameworks: e2 on top of OTP modlib for the web framework. Data storage: Riak 2.0.4 - storage of metadata. Storage of user data TBD. JSON - I hate XML. Eclipse rather than IntelliJ, simply because I've been using Eclipse for about 15 years. Linux. I hate MS worse than XML. But that's a "religious" issue which we really don't need to discuss, cuz it will get us nowhere. I would be happy to share my experiences with you as I progress through this project. Drop me a line any time. Thanks all, Michael On Fri, Feb 20, 2015 at 10:49 AM, David Welton wrote: > > Indeed, the great lure of frameworks are they make prior choices for you > > under the pretense the choices are correct and useful for your problem. > By > > making the decisions quickly, you get a minimum viable product faster and > > have a shorter time to market. In turn, you gain the de-facto monopoly > > anyone hopes to get. > > It doesn't even need to be about a monopoly, but about just getting > something out there and figuring out if there's a viable business > there at all. > > > So you need prior knowledge of what problem you need to solve, or it is > > square pegs through rounds holes all the way down. > > You don't necessarily get that, so sometimes it's best to get up and > running quickly and start learning. Maybe out of 5 features you had > in mind, the customers love 1 and buy your product for it, and don't > care much about the other 4. It's difficult to know that a priori. > > > The crux of my argument is based upon the prior choice of features. > First, you need prior knowledge of the framework itself. You need to know > its performance model: what is fast and what is slow. You need to know the > internal architecture. Otherwise, you are probably worse off than just > writing the code. A network effect is apparent: the more you work in a > framework, the more accumulated knowledge you have and the faster can you > build new stuff. The 10th Rails project is easier to write than the 1st. > Second, your problem has to match the frameworks framing, in the sense that > the problem space you are facing matches somewhat well with that of the > framework. As an example, it is hard to take the MVC pattern and fit into > an Event Sourcing/CQRS model. Of course you could learn a new framework, > but this requires prior knowledge as well. > > You actually may not need to know the framework that intimately. > There are a whole slew of problems that you could solve with pretty > much any old thing out there, given how bad existing solutions are. > > > My claim is that any interesting problem has high risk. > > For a business, at least, in a lot of cases the risk is 'market' risk, > though: http://ecorner.stanford.edu/authorMaterialInfo.html?mid=2325 - > which may not correspond to an 'interesting problem' in terms of > technology at all. You could use PHP and MongoDB and whatever other > icky tech, and it'd probably work out if you get that one key thing > that makes people want to buy your product. > > As a well-known example from the world of bootstrapped businesses: > http://www.bingocardcreator.com/ which has been amply discussed > online. He originally made it as a downloadable Java program, then > redid it as a Rails web application. Realistically, I'm sure he could > have used pretty much any old thing he knew well enough: the > 'interesting' part of BCC is not the technology, but the marketing he > put into it. > > > In turn, any > > interesting problem is unknown by definition. Hence, you don't know a > priori > > if your framework fits the problem in any way, and learning one is more > or > > less hit-or-miss. You may get a lucky strike, but it was definitely not > by > > considerate aiming of the weapon. > > From that point of view, even tools carry risks. Twitter started with > Ruby on Rails, which, much as it's nice for some things, is manifestly > the wrong thing to be using for what they do. Postgres, which I > happen to like a lot, is the wrong thing for some problems. Erlang > itself is the wrong tool if you need every last bit of performance > from your CPU to crunch numbers. And yet Erlang is still probably not > a bad starting place if you don't know that ahead of time: you could > use it to manage the number crunching code, and you're likely to get > some kind of system up and running a bit quicker than if you hand code > it in C. > > > This is why I prefer tools to frameworks. For a risky problem, the > freedom > > of picking tools for the job dwarf the advantage of using a framework. I > > thrive much better by gluing my own solution together. > > Backing away from the abstractions, the guy asked about creating a web > application. That's a known problem and involves some of the > following: > > * A web server. > * Something to connect it to to run code dynamically, rather than > simply serve static web pages. > * Some kind of templating system. > * Some kind of data store. > > Having a starting place that does all of that is a good jumping off > point for working on whatever it is that is actually interesting to > customers. Having something to start from also means you will > discover sooner, rather than later, if it's not adequate for what you > need, and give you firmer ideas about what you actually do need. > > This is also an information asymmetry problem: people who are just > getting started are the ones least able to evaluate a bunch of > disparate tools, so giving them something that at least *works* out of > the box is going to save them time and give them a leg up to a point > where they are more comfortable, understand more things, and are able > to start making any decisions about replacing bits and pieces or doing > things differently. > > -- > David N. Welton > > http://www.welton.it/davidw/ > > http://www.dedasys.com/ > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mmartin4242@REDACTED Fri Feb 20 18:48:24 2015 From: mmartin4242@REDACTED (Michael Martin) Date: Fri, 20 Feb 2015 12:48:24 -0500 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> Message-ID: I came to the same conclusions. HAProxy is my friend. On Fri, Feb 20, 2015 at 12:11 PM, Garrett Smith wrote: > On Fri, Feb 20, 2015 at 8:11 AM, Roberto Ostinelli > wrote: > > Dear List, > > Given the amount of answers I got in this post, I want to follow up and > give > > some additional information. > > > > After struggling for quite a while, I just did a comparison between using > > SSL connections vs standard TCP connections. > > The results are quite impressive. > > > > This is the diagram of memory evolution for a system under load, with > SSL: > > https://cldup.com/cNOc8hS004-2000x2000.png > > > > This is the same system, but without SSL: > > https://cldup.com/sx3RrdMR8o-3000x3000.png > > > > You can clearly see that using standard TCP connections the system is > > extremely stable. > > Using SSL connections, on the other hand, results in RAM memory having > very > > erratic behavior that ends up blowing up the node. > > > > Not sure what to do with this information, except that I'm going to use a > > SSL termination (HAProxy or ELB) and have my Erlang node run without SSL. > > This is my standard practice now - motivated by a number of production > issues. Fronting Erlang with an SSL proxy is completely trivial and > makes the pain go away. I guess it'd be nice if Erlang kept up with > the Nginxes and HAProxies, but not a must have. > _______________________________________________ > 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 Fri Feb 20 20:19:49 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Fri, 20 Feb 2015 20:19:49 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> Message-ID: As an addendum: I apologise because this cannot be clearly seen in the charts (I forgot to "humanise" the axis), but we're talking about a steady RAM usage of 4.5GB without SSL, in comparison to blowing up a node with 30GB with SSL. Best, r. On Fri, Feb 20, 2015 at 3:11 PM, Roberto Ostinelli wrote: > Dear List, > Given the amount of answers I got in this post, I want to follow up and > give some additional information. > > After struggling for quite a while, I just did a comparison between using > SSL connections vs standard TCP connections. > The results are quite impressive. > > This is the diagram of memory evolution for a system under load, with SSL: > https://cldup.com/cNOc8hS004-2000x2000.png > > This is the same system, but without SSL: > https://cldup.com/sx3RrdMR8o-3000x3000.png > > You can clearly see that using standard TCP connections the system is > extremely stable. > Using SSL connections, on the other hand, results in RAM memory having > very erratic behavior that ends up blowing up the node. > > Not sure what to do with this information, except that I'm going to use a > SSL termination (HAProxy or ELB) and have my Erlang node run without SSL. > > If anyone is curious just ping me. > > Best, > r. > > > > > > On Wed, Jan 28, 2015 at 8:09 PM, Roberto Ostinelli < > roberto.ostinelli@REDACTED> wrote: > >> That's a valid point, and I can clarify. >> >> During the first phase, all the long lived connections are made. During >> the second phase, newly-created short lived connections send messages to >> the long lived ones. >> >> The long lived connection are all connected when the first memory >> increase phase ends, which is when the short-lived connections start >> sending messages. >> >> What is unclear to me is why the second memory increase phase happens >> quite some time after these short lived processes have started sending >> messages. >> >> >> > On 28/gen/2015, at 20:02, Anton Lebedevich wrote: >> > >> > The graph looks really weird for me assuming that the load applied to >> > the system is stable. Why does it go down for a short time and then >> > jumps higher than it was? >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nyarly@REDACTED Fri Feb 20 20:46:49 2015 From: nyarly@REDACTED (Judson Lester) Date: Fri, 20 Feb 2015 19:46:49 +0000 Subject: [erlang-questions] Extracting pure functions Message-ID: I'm thinking about how to separate pure functions from those that cause side effects, and one of the places I'm trying to find a decent pattern for is message passing. I'm primarily concerned with being able to easily test the functional components as units, and then use integration testing for the parts that involve a side effect. For instance, I have a gen_server that handles a message and emits an event sometimes. handle_event_message(Arg, State=#state{collected_args=Args,event_server=Ev}) -> gen_event:notify(Ev, {some_event, Arg}), State#state{collected_args[Arg |Args]}. (obviously, I'm simplifying a lot here) What I'm wondering about is extracting something like: handle_event_message(Arg, State=#state{collected_args=Args,event_server=Ev}) -> {Effects, State} = pure_handle(Arg, State), [ apply(Mod, Fun, Args) || {Mod, Fun, Args} <- Effects], State. pure_handle(Arg, State) -> { [{gen_event, notify, [Ev, {some_event, Arg}]}], State#state{collected_args[Arg |Args]} }. Which would mean I could test the effects that pure_handle/2 intends in a unit test. Is this a pattern others use? A terrible delusion? Not interesting? Judson -------------- next part -------------- An HTML attachment was scrubbed... URL: From gguthrie@REDACTED Fri Feb 20 21:35:09 2015 From: gguthrie@REDACTED (Gordon Guthrie) Date: Fri, 20 Feb 2015 20:35:09 +0000 Subject: [erlang-questions] Extracting pure functions In-Reply-To: References: Message-ID: <6408A962-7D98-43F3-967F-2FD290FF1534@basho.com> Judson That mechanism is perfect for building highly testable services. Effectively you are transforming the testing domain from: * if I receive these inputs then I emit these side effects to: * if I were to receive these inputs then I would have emitted these side effects To test the former you have two choices: * build a full system test * meck the living bejesus out of your system This mechanism is particularly useful if the serve contains a large data structure that needs to be manipulated in memory. Gordon > Le 20 f?vr. 2015 ? 19:46, Judson Lester a ?crit : > > I'm thinking about how to separate pure functions from those that cause side effects, and one of the places I'm trying to find a decent pattern for is message passing. > > I'm primarily concerned with being able to easily test the functional components as units, and then use integration testing for the parts that involve a side effect. > > For instance, I have a gen_server that handles a message and emits an event sometimes. > > handle_event_message(Arg, State=#state{collected_args=Args,event_server=Ev}) -> > gen_event:notify(Ev, {some_event, Arg}), > State#state{collected_args[Arg |Args]}. > > (obviously, I'm simplifying a lot here) > > What I'm wondering about is extracting something like: > > handle_event_message(Arg, State=#state{collected_args=Args,event_server=Ev}) -> > {Effects, State} = pure_handle(Arg, State), > [ apply(Mod, Fun, Args) || {Mod, Fun, Args} <- Effects], > State. > > pure_handle(Arg, State) -> > { [{gen_event, notify, [Ev, {some_event, Arg}]}], > State#state{collected_args[Arg |Args]} }. > > Which would mean I could test the effects that pure_handle/2 intends in a unit test. > > Is this a pattern others use? A terrible delusion? Not interesting? > > Judson > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From marc@REDACTED Sat Feb 21 00:14:00 2015 From: marc@REDACTED (Marc Worrell) Date: Sat, 21 Feb 2015 00:14:00 +0100 Subject: [erlang-questions] [ANNOUNCE] Zotonic release 0.12.4 Message-ID: <30B8AC32-58D3-48FE-8C3A-466E8E092158@worrell.nl> Hi, Zotonic is the open source, web framework and content management system, built with Erlang. It is flexible, extensible and designed to support dynamic, interactive websites and mobile solutions. - See more at: http://zotonic.com/ We have just released Zotonic 0.12.4. The highlights of this release include two new modules for integrating with LinkedIn and Instagram. Furthermore there are improvements to the CSV import module and many additions to the documentation. Complete release notes are at: http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.4.html Depending on the progress of some lower-level changes we might rename the 0.13 release to 1.0? I will publish more information on our plans later. Kind Regards. Marc Worrell PS. Check also the earlier releases, which we tagged quite silently. 0.12.3: ? Fix of the twerl git url in rebar.config.lock ? New z_stdlib, fixing issues with url metadata extraction ? Sanitization of oembed content ? Addition of Font Awesome 4 ? Extended Zotonic logo font http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.3.html 0.12.2: ? Addition of new notifications for importing media. ? Authentication using mod_twitter and mod_facebook is now via a popup window ? mod_twitter can now follow keywords and multiple users ? New admin menu item Auth -> App Keys & Authentication Services http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.2.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From lloyd@REDACTED Sat Feb 21 00:18:27 2015 From: lloyd@REDACTED (lloyd@REDACTED) Date: Fri, 20 Feb 2015 18:18:27 -0500 (EST) Subject: [erlang-questions] [ANNOUNCE] Zotonic release 0.12.4 In-Reply-To: <30B8AC32-58D3-48FE-8C3A-466E8E092158@worrell.nl> References: <30B8AC32-58D3-48FE-8C3A-466E8E092158@worrell.nl> Message-ID: <1424474307.76947754@apps.rackspace.com> Congrats, Mark! LRP -----Original Message----- From: "Marc Worrell" Sent: Friday, February 20, 2015 6:14pm To: "Erlang Questions" Subject: [erlang-questions] [ANNOUNCE] Zotonic release 0.12.4 Hi, Zotonic is the open source, web framework and content management system, built with Erlang. It is flexible, extensible and designed to support dynamic, interactive websites and mobile solutions. - See more at: [ http://zotonic.com/ ]( http://zotonic.com/ ) We have just released Zotonic 0.12.4. The highlights of this release include two new modules for integrating with LinkedIn and Instagram. Furthermore there are improvements to the CSV import module and many additions to the documentation. Complete release notes are at: [ http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.4.html ]( http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.4.html ) Depending on the progress of some lower-level changes we might rename the 0.13 release to 1.0? I will publish more information on our plans later. Kind Regards. Marc Worrell PS. Check also the earlier releases, which we tagged quite silently. 0.12.3: ? Fix of the twerl git url in rebar.config.lock ? New z_stdlib, fixing issues with url metadata extraction ? Sanitization of oembed content ? Addition of Font Awesome 4 ? Extended Zotonic logo font [ http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.3.html ]( http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.3.html ) 0.12.2:? Addition of new notifications for importing media. ??Authentication using mod_twitter and mod_facebook is now via a popup window ??mod_twitter can now follow keywords and multiple users ??New admin menu item Auth -> App Keys & Authentication Services [ http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.2.html ]( http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.2.html ) -------------- next part -------------- An HTML attachment was scrubbed... URL: From gumm@REDACTED Sat Feb 21 01:56:53 2015 From: gumm@REDACTED (Jesse Gumm) Date: Fri, 20 Feb 2015 18:56:53 -0600 Subject: [erlang-questions] [ANNOUNCE] Zotonic release 0.12.4 In-Reply-To: <1424474307.76947754@apps.rackspace.com> References: <30B8AC32-58D3-48FE-8C3A-466E8E092158@worrell.nl> <1424474307.76947754@apps.rackspace.com> Message-ID: Big fat congrats on the release, and impending 1.0 release, Marc! Keep pluggin' away! -Jesse On Fri, Feb 20, 2015 at 5:18 PM, wrote: > Congrats, Mark! > > > > LRP > > > > -----Original Message----- > From: "Marc Worrell" > Sent: Friday, February 20, 2015 6:14pm > To: "Erlang Questions" > Subject: [erlang-questions] [ANNOUNCE] Zotonic release 0.12.4 > > Hi, > Zotonic is the open source, web framework and content management system, > built with Erlang. It is flexible, extensible and designed to support > dynamic, interactive websites and mobile solutions. - See more at: > http://zotonic.com/ > We have just released Zotonic 0.12.4. > The highlights of this release include two new modules for integrating with > LinkedIn and Instagram. > Furthermore there are improvements to the CSV import module and many > additions to the documentation. > > Complete release notes are at: > > http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.4.html > > Depending on the progress of some lower-level changes we might rename the > 0.13 release to 1.0? > I will publish more information on our plans later. > Kind Regards. > Marc Worrell > PS. Check also the earlier releases, which we tagged quite silently. > 0.12.3: > ? Fix of the twerl git url in rebar.config.lock > ? New z_stdlib, fixing issues with url metadata extraction > ? Sanitization of oembed content > ? Addition of Font Awesome 4 > ? Extended Zotonic logo font > http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.3.html > > > > 0.12.2: > > ? Addition of new notifications for importing media. > ? Authentication using mod_twitter and mod_facebook is now via a popup > window > ? mod_twitter can now follow keywords and multiple users > ? New admin menu item Auth -> App Keys & Authentication Services > > http://zotonic.com/docs/latest/dev/releasenotes/rel_0.12.2.html > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Jesse Gumm Owner, Sigma Star Systems 414.940.4866 || sigma-star.com || @jessegumm From atill@REDACTED Sat Feb 21 12:30:57 2015 From: atill@REDACTED (Andy Till) Date: Sat, 21 Feb 2015 11:30:57 +0000 Subject: [erlang-questions] Extracting pure functions In-Reply-To: <6408A962-7D98-43F3-967F-2FD290FF1534@basho.com> References: <6408A962-7D98-43F3-967F-2FD290FF1534@basho.com> Message-ID: <54E86C71.7030506@mail.com> I suggest caution before applying this technique liberally to production apps. We had a couple of projects with a lot of code like this and it is very difficult to work with. It differs slightly from your example, it didn't return MFAs, just tuples which would be matched in a "process_side_effects" function which applied all the side effects. That meant you had to zip up and down the module to find the whole implementation for a function of logic plus side effects. Where I found issues is in the inflexibility in handling errors. Not crash bug errors but stuff like econnrefused from a socket, so you have to handle it in the side effect function. Then there is logic in two places. It also defies all editor navigation and static analysis tools like ctags and xref. I created a behaviour for this pattern (gen_io on github) but decided not to use it so treat it as highly experimental. On 20/02/2015 20:35, Gordon Guthrie wrote: > Judson > > That mechanism is perfect for building highly testable services. > > Effectively you are transforming the testing domain from: > * if I receive these inputs then I emit these side effects > > to: > * if I were to receive these inputs then I would have emitted these side effects > > To test the former you have two choices: > * build a full system test > * meck the living bejesus out of your system > > This mechanism is particularly useful if the serve contains a large data structure that needs to be manipulated in memory. > > Gordon > >> Le 20 f?vr. 2015 ? 19:46, Judson Lester a ?crit : >> >> I'm thinking about how to separate pure functions from those that cause side effects, and one of the places I'm trying to find a decent pattern for is message passing. >> >> I'm primarily concerned with being able to easily test the functional components as units, and then use integration testing for the parts that involve a side effect. >> >> For instance, I have a gen_server that handles a message and emits an event sometimes. >> >> handle_event_message(Arg, State=#state{collected_args=Args,event_server=Ev}) -> >> gen_event:notify(Ev, {some_event, Arg}), >> State#state{collected_args[Arg |Args]}. >> >> (obviously, I'm simplifying a lot here) >> >> What I'm wondering about is extracting something like: >> >> handle_event_message(Arg, State=#state{collected_args=Args,event_server=Ev}) -> >> {Effects, State} = pure_handle(Arg, State), >> [ apply(Mod, Fun, Args) || {Mod, Fun, Args} <- Effects], >> State. >> >> pure_handle(Arg, State) -> >> { [{gen_event, notify, [Ev, {some_event, Arg}]}], >> State#state{collected_args[Arg |Args]} }. >> >> Which would mean I could test the effects that pure_handle/2 intends in a unit test. >> >> Is this a pattern others use? A terrible delusion? Not interesting? >> >> Judson >> _______________________________________________ >> 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 jesper.louis.andersen@REDACTED Sat Feb 21 15:19:14 2015 From: jesper.louis.andersen@REDACTED (Jesper Louis Andersen) Date: Sat, 21 Feb 2015 15:19:14 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> Message-ID: On Fri, Feb 20, 2015 at 6:11 PM, Garrett Smith wrote: > This is my standard practice now - motivated by a number of production > issues. Fronting Erlang with an SSL proxy is completely trivial and > makes the pain go away. I guess it'd be nice if Erlang kept up with > the Nginxes and HAProxies, but not a must have. > Another tool, which WhatsApp aimed on was stud: https://github.com/bumptech/stud though the 200k buffer space per connection sound awfully large for a large installation with lots of connections going on. -- J. -------------- next part -------------- An HTML attachment was scrubbed... URL: From luis.azedo@REDACTED Sat Feb 21 15:53:26 2015 From: luis.azedo@REDACTED (Luis Azedo) Date: Sat, 21 Feb 2015 14:53:26 +0000 Subject: [erlang-questions] application uptime Message-ID: Hi, is there a simple way to get an application uptime ? (not node uptime) Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From mfidelman@REDACTED Sat Feb 21 21:45:03 2015 From: mfidelman@REDACTED (Miles Fidelman) Date: Sat, 21 Feb 2015 15:45:03 -0500 Subject: [erlang-questions] Erlang based C2ISR system In-Reply-To: References: <1488951.nvtsoKpDl8@changa> Message-ID: <54E8EE4F.3050409@meetinghouse.net> I think I'm going to respond with exactly the opposite conclusion. I see lots of use cases for Erlang in C2ISR, and am working on some of them. More below, in-line and at the end..... > On Tue, Feb 17, 2015 at 9:05 AM, zxq9 > wrote: > > On 2015?2?17? ??? 11:47:32 Rizwan Khan wrote: > > Any one knows if Erlang is being used anywhere for Command and > Control or > > ISR systems which are normally for the armed forces. > > > > I am not too sure if that would be a good fit either. May be in > terms for > > distributed computing and surely not for image processing related > > applications. > > A somewhat long-winded response follows, much of it anecdotal. I'm > trying to > give enough background for the OP to understand the situation that > exists at > the C2 level, the tactical level, and what I have seen in a C2&T > project I've > worked on, and what I have externally observed about another very > similar one. > > ~~~~~~ > > I doubt it is. In any case, of the bajillion or so supposedly > interoperable C2 > systems I ever took the time to peek into, every one seemed to be > written > against a different combination of language/platform/environment > assumptions. > Whether or not Erlang is a good fit for C2 (and in many cases it > certainly may > be), it seems to have about zero mindshare within the military. > > At a larger TOC there was usually a guy or section whose task it > was to > aggregate data so various folks could access it or use it -- more > often than > not, though, a TOC (whether a FOB, JSOTF, JSOTF-forward, or an > *actual* TOC) > is a blackhole for information. > > In SF our 18E/F/Cs (or whoever on the team had significant > computer knowledge > and could work with the 18E) would deal with receiving, say, UAV > imagery > directly from the pilot's direct feed or (usually better) from > whatever laptop > software could talk to it, convert it to something he could send > over the air, > and relay it that way. Data from outside the team might be handled > the same > way (if there was time), but usually a one-off system existed for > each type of > asset we might be working with (like an application that handles > one specific > type of video from one particular source, an entire > hardware-kit-in-a-suitcase > for receiving P3 imagery live, a special video box with no digital > output so > we could (maybe) watch a particular feed, etc.) and very often > there just > isn't time to mess with aggregation in a useful way until long > after the fun > is over. > > Of course, at the TOC, where all the folks who don't actually do > anything > operational hang out, all sorts of data is supposedly aggregated > -- but I've > seen exactly zero evidence of that in practice. I suspect that > roughly half > the blame for the blackholiness of TOCs (and other echelons beyond > reality in > general) belongs to the bureaucratic sloth that manifests in any > large, rigid > organization, and the other half probably belongs to the fact that > every > single system is completely different from every other system (and > that itself > is a product of the nature of acquisitions within large > bureaucracies). > Sorting through all the miles of piles of data that pour in to a > TOC after- > the-fact is a much lower priority than ongoing operations (or than > printing > random memoranda about authorized holster models, etc.), so the > monumental > task of untangling the digital/analog Gordian Knot appears to > rarely be > undertaken in a serious way -- at least from what I witnessed. I > don't think > there is really any way around this, though the situation could > certainly be a > bit less ridiculous. > Just to be clear... here, you're really talking the ISR and data fusion aspects of C2ISR, not C2. In this domain, about the best example of interoperability I've seen is cursor-on-target, which is basically a protocol for moving information around. Erlang is a great environment for writing protocol engines. On the fusion side, AFRL used to have a neat little concept called "fuselets" - essentially distributed agents linked into data flow networks that aggregated information from multiple sources. Like most distributed agent work, it was all done in Java - a horrible environment for this kind of thing. We're really talking an actor formalism, which is what Erlang is perfect for. On the C2 side, it's worth noting that an awful lot of stuff flows over Jopes - in the form of classic nntp newsgroups; and most of what passes for C2 is really message traffic. Again, we're talking protocol activities, for which erlang ideal. And, on a different note, I've periodically though that the distributed training model - synchronized copies of the same "world model," using protocols like DIS and HLA - would be a great model for a distributed common operating picture. Again... protocols and protocol engines. Cheers, Miles Fidelman -- In theory, there is no difference between theory and practice. In practice, there is. .... Yogi Berra From harit.subscriptions@REDACTED Sun Feb 22 00:21:32 2015 From: harit.subscriptions@REDACTED (Harit Himanshu) Date: Sat, 21 Feb 2015 15:21:32 -0800 Subject: [erlang-questions] List Split into [H|T] is not working Message-ID: Hey there, I am pretty sure I am messing up, but can't figure out really. Here is what I do -module(solution). -export([main/0]). main() -> Input = read_input([]), [S | X] = Input, io:format("S=~p, X=~p~n", [S, X]), repeat(S, X). read_input(Input) -> case io:fread("", "~d") of {ok, [N]} -> read_input([N | Input]); _ -> [lists:reverse(Input)] end. and when I run it, I get 5> c(solution). solution.erl:20: Warning: function string_to_integer_list/1 is unused {ok,solution} 6> solution:main(). 2 3 4 5 . S=[2,3,4,5], X=[] ok 7> What's wrong here? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From harit.subscriptions@REDACTED Sun Feb 22 00:24:27 2015 From: harit.subscriptions@REDACTED (Harit Himanshu) Date: Sat, 21 Feb 2015 15:24:27 -0800 Subject: [erlang-questions] List Split into [H|T] is not working In-Reply-To: References: Message-ID: Just figured that _ -> [lists:reverse(Input)] should be _ -> lists:reverse(Input) On Sat, Feb 21, 2015 at 3:21 PM, Harit Himanshu < harit.subscriptions@REDACTED> wrote: > Hey there, > > I am pretty sure I am messing up, but can't figure out really. > > Here is what I do > > -module(solution). > > -export([main/0]). > > main() -> > Input = read_input([]), > [S | X] = Input, > io:format("S=~p, X=~p~n", [S, X]), > repeat(S, X). > > read_input(Input) -> > case io:fread("", "~d") of > {ok, [N]} -> read_input([N | Input]); > _ -> [lists:reverse(Input)] > end. > > > and when I run it, I get > > 5> c(solution). > > solution.erl:20: Warning: function string_to_integer_list/1 is unused > > {ok,solution} > > 6> solution:main(). > > 2 > > 3 > > 4 > > 5 > > . > > S=[2,3,4,5], X=[] > > ok > > 7> > > > What's wrong here? > > Thanks > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Mon Feb 23 01:55:33 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Mon, 23 Feb 2015 13:55:33 +1300 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: On 21/02/2015, at 2:37 am, David Welton wrote: >> Never pick a "framework", since they always limit you in the long run. If I >> *had* to, I would research nitrogen or n2o. A framework has technical merits, flaws, and limitations. It also has a community of people who (puts on cynic's hat) have a strong self-interest in seeing other people succeed with it in order to validate their self-investment in it. So it's not just what _you_ can do in a framework, it's what you can be _helped_ to do by the proponents of it. (And with some frameworks, it's what you can stealXXXXXcopy.) From rizkhan@REDACTED Mon Feb 23 06:44:44 2015 From: rizkhan@REDACTED (Rizwan Khan) Date: Mon, 23 Feb 2015 10:44:44 +0500 Subject: [erlang-questions] Erlang based C2ISR system In-Reply-To: <54E8EE4F.3050409@meetinghouse.net> References: <1488951.nvtsoKpDl8@changa> <54E8EE4F.3050409@meetinghouse.net> Message-ID: Thanks for the input Miles. Do we have any implementation for fuselets or Jopes DIS/HLA etc in Erlang already? Rizwan Khan On Sun, Feb 22, 2015 at 1:45 AM, Miles Fidelman wrote: > I think I'm going to respond with exactly the opposite conclusion. I see > lots of use cases for Erlang in C2ISR, and am working on some of them. > More below, in-line and at the end..... > > > On Tue, Feb 17, 2015 at 9:05 AM, zxq9 > zxq9@REDACTED>> wrote: >> >> On 2015?2?17? ??? 11:47:32 Rizwan Khan wrote: >> > Any one knows if Erlang is being used anywhere for Command and >> Control or >> > ISR systems which are normally for the armed forces. >> > >> > I am not too sure if that would be a good fit either. May be in >> terms for >> > distributed computing and surely not for image processing related >> > applications. >> >> A somewhat long-winded response follows, much of it anecdotal. I'm >> trying to >> give enough background for the OP to understand the situation that >> exists at >> the C2 level, the tactical level, and what I have seen in a C2&T >> project I've >> worked on, and what I have externally observed about another very >> similar one. >> >> ~~~~~~ >> >> I doubt it is. In any case, of the bajillion or so supposedly >> interoperable C2 >> systems I ever took the time to peek into, every one seemed to be >> written >> against a different combination of language/platform/environment >> assumptions. >> Whether or not Erlang is a good fit for C2 (and in many cases it >> certainly may >> be), it seems to have about zero mindshare within the military. >> >> At a larger TOC there was usually a guy or section whose task it >> was to >> aggregate data so various folks could access it or use it -- more >> often than >> not, though, a TOC (whether a FOB, JSOTF, JSOTF-forward, or an >> *actual* TOC) >> is a blackhole for information. >> >> In SF our 18E/F/Cs (or whoever on the team had significant >> computer knowledge >> and could work with the 18E) would deal with receiving, say, UAV >> imagery >> directly from the pilot's direct feed or (usually better) from >> whatever laptop >> software could talk to it, convert it to something he could send >> over the air, >> and relay it that way. Data from outside the team might be handled >> the same >> way (if there was time), but usually a one-off system existed for >> each type of >> asset we might be working with (like an application that handles >> one specific >> type of video from one particular source, an entire >> hardware-kit-in-a-suitcase >> for receiving P3 imagery live, a special video box with no digital >> output so >> we could (maybe) watch a particular feed, etc.) and very often >> there just >> isn't time to mess with aggregation in a useful way until long >> after the fun >> is over. >> >> Of course, at the TOC, where all the folks who don't actually do >> anything >> operational hang out, all sorts of data is supposedly aggregated >> -- but I've >> seen exactly zero evidence of that in practice. I suspect that >> roughly half >> the blame for the blackholiness of TOCs (and other echelons beyond >> reality in >> general) belongs to the bureaucratic sloth that manifests in any >> large, rigid >> organization, and the other half probably belongs to the fact that >> every >> single system is completely different from every other system (and >> that itself >> is a product of the nature of acquisitions within large >> bureaucracies). >> Sorting through all the miles of piles of data that pour in to a >> TOC after- >> the-fact is a much lower priority than ongoing operations (or than >> printing >> random memoranda about authorized holster models, etc.), so the >> monumental >> task of untangling the digital/analog Gordian Knot appears to >> rarely be >> undertaken in a serious way -- at least from what I witnessed. I >> don't think >> there is really any way around this, though the situation could >> certainly be a >> bit less ridiculous. >> >> > Just to be clear... here, you're really talking the ISR and data fusion > aspects of C2ISR, not C2. In this domain, about the best example of > interoperability I've seen is cursor-on-target, which is basically a > protocol for moving information around. Erlang is a great environment for > writing protocol engines. > > On the fusion side, AFRL used to have a neat little concept called > "fuselets" - essentially distributed agents linked into data flow networks > that aggregated information from multiple sources. Like most distributed > agent work, it was all done in Java - a horrible environment for this kind > of thing. We're really talking an actor formalism, which is what Erlang is > perfect for. > > On the C2 side, it's worth noting that an awful lot of stuff flows over > Jopes - in the form of classic nntp newsgroups; and most of what passes for > C2 is really message traffic. Again, we're talking protocol activities, > for which erlang ideal. > > And, on a different note, I've periodically though that the distributed > training model - synchronized copies of the same "world model," using > protocols like DIS and HLA - would be a great model for a distributed > common operating picture. Again... protocols and protocol engines. > > Cheers, > > Miles Fidelman > > -- > In theory, there is no difference between theory and practice. > In practice, there is. .... Yogi Berra > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidnwelton@REDACTED Mon Feb 23 10:10:17 2015 From: davidnwelton@REDACTED (David Welton) Date: Mon, 23 Feb 2015 10:10:17 +0100 Subject: [erlang-questions] your first choice? In-Reply-To: References: Message-ID: >>> Never pick a "framework", since they always limit you in the long run. If I >>> *had* to, I would research nitrogen or n2o. > > A framework has technical merits, flaws, and limitations. > It also has a community of people who (puts on cynic's hat) > have a strong self-interest in seeing other people succeed > with it in order to validate their self-investment in it. In economics, the concept is called "positive network externalities" or "network effects": http://en.wikipedia.org/wiki/Network_effect - and it's not just about 'self validation'. It's something that's a factor in most programming languages and other tools we use. The more people use Erlang (or PHP, or Ruby or Visual Forth ++ or whatever), the more libraries there are likely to be. There will be more books, and more jobs, and more people to hire if you create a company. It's a real and tangible benefit to have other people to ask for help, or that write packages that you can use easily. So trying to get other people on board with whatever is probably in your own self-interest, to some degree, long term, even though the actual benefits at the margin are not large. I'd highly recommend this book for a more thorough discussion of the economics of 'information goods', which of course includes programming languages: http://www.amazon.com/Information-Rules-Strategic-Network-Economy/dp/087584863X - one of the authors is now the chief economist at Google. > So it's not just what _you_ can do in a framework, > it's what you can be _helped_ to do by the proponents of it. > (And with some frameworks, it's what you can stealXXXXXcopy.) Most good frameworks are just a nice collection of pieces without too much glue to hold them together, so, yes, you can certainly take what you like from them, and perhaps replace it with other bits and pieces more to your liking. This presumes, of course, that you're proficient with the language and its libraries, and with the problem you're trying to solve. You might consider the purpose of a framework as helping to get you to that point in the first place. -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From roger@REDACTED Mon Feb 23 16:17:41 2015 From: roger@REDACTED (Roger Lipscombe) Date: Mon, 23 Feb 2015 15:17:41 +0000 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug? Message-ID: I'm attempting to use spawn_opt/3 with a remote node, like this: Fun = fun() -> ok end, {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). It fails with: {badarg, [{erlang,spawn_opt, ['imp_server@REDACTED',erlang,apply, [#Fun,[]], [link,monitor]], []} Now, the documentation at http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the 'monitor' option is not allowed for spawn_opt/5. It says nothing about spawn_opt/3. Looking at the error message, it looks like spawn_opt/3 simply calls spawn_opt/5. Does this note about 'monitor' being unsupported need to be in documentation for both functions? From roger@REDACTED Mon Feb 23 16:21:12 2015 From: roger@REDACTED (Roger Lipscombe) Date: Mon, 23 Feb 2015 15:21:12 +0000 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. How to monitor a remote process? Message-ID: Note that, despite the preamble, this is a different question to the other one I just posted. Honest. I'm attempting to use spawn_opt/3 with a remote node, like this: Fun = fun() -> ok end, {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). It fails with badarg. How do I monitor a process that I spawn on a remote node? If I use spawn_link followed by monitor, there's a race where the remote process could have exited already, and I get {'DOWN', Ref, process, Pid, noproc}, which is disconcerting. I want to know when it's finished. Preferably without it needing to explicitly send a message back to me. From carlosj.gf@REDACTED Mon Feb 23 19:24:12 2015 From: carlosj.gf@REDACTED (=?ISO-8859-1?Q?Carlos_Gonz=E1lez_Florido?=) Date: Mon, 23 Feb 2015 19:24:12 +0100 Subject: [erlang-questions] [ANN] NkBASE released Message-ID: Hello Erlangers, I'm very happy to announce that we have released the first version of NkBASE, a distributed, highly available key-value database designed to be integrated into riak_core based Erlang applications. NkBASE is one of the core pieces of the upcoming Nekso's Software Defined Data Center Platform, NetComposer. NkBASE has some interesting features: - Highly available, allowing read and write operations even in case of node failures. - Operation friendly. Nodes can be added and removed on the fly. - Scalable from three to hundreds of nodes. - Disk (leveldb) and memory (ets) backends. - Three simultaneous operation modes: - Eventually consistent mode using Dotted Version Vectors. - Strong consistent mode based on using riak_ensemble's multi-paxos. - Easy to use, self-convergent CRDTs called dmaps. - Multiple, auto-generated secondary indices, usable in the three modes. - Can use any Erlang term as domain, class, key, value, index or index value. - Simple, easy to use, utf8 and latin-1 aware query language for secondary indices. - Full support for auto-expiration of objects, with configurable resolution. NkBASE has a clean code base, and can be used as a starting point to learn how to build a distributed Erlang system on top of riak_core, or to test new backends or replication mechanisms. NkBASE heavily relies on the impressive riak_core, riak_dt and riak_ensemble from Basho. Try it at https://github.com/Nekso/nkbase. Comments are very welcomed! Carlos Gonzalez @carlosjgf https://www.linkedin.com/in/carlosjgf -------------- next part -------------- An HTML attachment was scrubbed... URL: From e@REDACTED Mon Feb 23 21:07:43 2015 From: e@REDACTED (e@REDACTED) Date: Mon, 23 Feb 2015 21:07:43 +0100 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug? In-Reply-To: References: Message-ID: <54EB888F.3040504@bestmx.net> the 0-ary function does not unify with a pair of arguments provided. i suspect this is the issue. On 02/23/2015 04:17 PM, Roger Lipscombe wrote: > I'm attempting to use spawn_opt/3 with a remote node, like this: > > Fun = fun() -> ok end, > {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). > > It fails with: > > {badarg, > [{erlang,spawn_opt, > ['imp_server@REDACTED',erlang,apply, > [#Fun,[]], > [link,monitor]], > []} > > Now, the documentation at > http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the > 'monitor' option is not allowed for spawn_opt/5. It says nothing about > spawn_opt/3. > > Looking at the error message, it looks like spawn_opt/3 simply calls > spawn_opt/5. Does this note about 'monitor' being unsupported need to > be in documentation for both functions? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > From e@REDACTED Mon Feb 23 21:12:10 2015 From: e@REDACTED (e@REDACTED) Date: Mon, 23 Feb 2015 21:12:10 +0100 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug? In-Reply-To: <54EB888F.3040504@bestmx.net> References: <54EB888F.3040504@bestmx.net> Message-ID: <54EB899A.50005@bestmx.net> NO, i am wrong! ignore the previous message On 02/23/2015 09:07 PM, e@REDACTED wrote: > the 0-ary function > does not unify with a pair of arguments provided. > i suspect this is the issue. > > > On 02/23/2015 04:17 PM, Roger Lipscombe wrote: >> I'm attempting to use spawn_opt/3 with a remote node, like this: >> >> Fun = fun() -> ok end, >> {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). >> >> It fails with: >> >> {badarg, >> [{erlang,spawn_opt, >> ['imp_server@REDACTED',erlang,apply, >> [#Fun,[]], >> [link,monitor]], >> []} >> >> Now, the documentation at >> http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the >> 'monitor' option is not allowed for spawn_opt/5. It says nothing about >> spawn_opt/3. >> >> Looking at the error message, it looks like spawn_opt/3 simply calls >> spawn_opt/5. Does this note about 'monitor' being unsupported need to >> be in documentation for both functions? >> _______________________________________________ >> 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 rpettit@REDACTED Mon Feb 23 21:13:40 2015 From: rpettit@REDACTED (Rick Pettit) Date: Mon, 23 Feb 2015 14:13:40 -0600 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug? In-Reply-To: <54EB888F.3040504@bestmx.net> References: <54EB888F.3040504@bestmx.net> Message-ID: <0E00F097-DDB9-48F9-826A-622BA605983B@vailsys.com> I might have guessed the same, as I do not use spawn_opt/x much ? but looking at the documentation for spawn_opt/3, that third argument is the set of *options* for the spawn opt, and *not* the set of arguments to pass to the fun. -Rick > On Feb 23, 2015, at 2:07 PM, e@REDACTED wrote: > > the 0-ary function > does not unify with a pair of arguments provided. > i suspect this is the issue. > > > On 02/23/2015 04:17 PM, Roger Lipscombe wrote: >> I'm attempting to use spawn_opt/3 with a remote node, like this: >> >> Fun = fun() -> ok end, >> {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). >> >> It fails with: >> >> {badarg, >> [{erlang,spawn_opt, >> ['imp_server@REDACTED',erlang,apply, >> [#Fun,[]], >> [link,monitor]], >> []} >> >> Now, the documentation at >> http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the >> 'monitor' option is not allowed for spawn_opt/5. It says nothing about >> spawn_opt/3. >> >> Looking at the error message, it looks like spawn_opt/3 simply calls >> spawn_opt/5. Does this note about 'monitor' being unsupported need to >> be in documentation for both functions? >> _______________________________________________ >> 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 rvirding@REDACTED Tue Feb 24 00:53:32 2015 From: rvirding@REDACTED (Robert Virding) Date: Tue, 24 Feb 2015 00:53:32 +0100 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug? In-Reply-To: <0E00F097-DDB9-48F9-826A-622BA605983B@vailsys.com> References: <54EB888F.3040504@bestmx.net> <0E00F097-DDB9-48F9-826A-622BA605983B@vailsys.com> Message-ID: The implication is that as it does not work with spawn_opt/5 which spawns a process on another node then it will also not work for spawn_opt/3 which does the same thing. Whether you give a fun or Mod,Fun,Args is irrelevant here. Another reason for getting the badarg is the fun. To pass and call funs on other nodes requires exactly the same version of the module in which the fun is defined, in this case erl_eval. An easy way to test this is to just try and spawn the fun on the other node with spawn/2. If that works then this is not the problem. Robert On 23 February 2015 at 21:13, Rick Pettit wrote: > I might have guessed the same, as I do not use spawn_opt/x much ? but > looking at the documentation for spawn_opt/3, that third argument is the > set of *options* for the spawn opt, and *not* the set of arguments to pass > to the fun. > > -Rick > > > On Feb 23, 2015, at 2:07 PM, e@REDACTED wrote: > > > > the 0-ary function > > does not unify with a pair of arguments provided. > > i suspect this is the issue. > > > > > > On 02/23/2015 04:17 PM, Roger Lipscombe wrote: > >> I'm attempting to use spawn_opt/3 with a remote node, like this: > >> > >> Fun = fun() -> ok end, > >> {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). > >> > >> It fails with: > >> > >> {badarg, > >> [{erlang,spawn_opt, > >> ['imp_server@REDACTED',erlang,apply, > >> [#Fun,[]], > >> [link,monitor]], > >> []} > >> > >> Now, the documentation at > >> http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the > >> 'monitor' option is not allowed for spawn_opt/5. It says nothing about > >> spawn_opt/3. > >> > >> Looking at the error message, it looks like spawn_opt/3 simply calls > >> spawn_opt/5. Does this note about 'monitor' being unsupported need to > >> be in documentation for both functions? > >> _______________________________________________ > >> 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 rvirding@REDACTED Tue Feb 24 00:54:25 2015 From: rvirding@REDACTED (Robert Virding) Date: Tue, 24 Feb 2015 00:54:25 +0100 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug? In-Reply-To: References: <54EB888F.3040504@bestmx.net> <0E00F097-DDB9-48F9-826A-622BA605983B@vailsys.com> Message-ID: Which versions of erlang are you running on the nodes? On 24 February 2015 at 00:53, Robert Virding wrote: > The implication is that as it does not work with spawn_opt/5 which spawns > a process on another node then it will also not work for spawn_opt/3 which > does the same thing. Whether you give a fun or Mod,Fun,Args is irrelevant > here. > > Another reason for getting the badarg is the fun. To pass and call funs on > other nodes requires exactly the same version of the module in which the > fun is defined, in this case erl_eval. An easy way to test this is to just > try and spawn the fun on the other node with spawn/2. If that works then > this is not the problem. > > Robert > > > On 23 February 2015 at 21:13, Rick Pettit wrote: > >> I might have guessed the same, as I do not use spawn_opt/x much ? but >> looking at the documentation for spawn_opt/3, that third argument is the >> set of *options* for the spawn opt, and *not* the set of arguments to pass >> to the fun. >> >> -Rick >> >> > On Feb 23, 2015, at 2:07 PM, e@REDACTED wrote: >> > >> > the 0-ary function >> > does not unify with a pair of arguments provided. >> > i suspect this is the issue. >> > >> > >> > On 02/23/2015 04:17 PM, Roger Lipscombe wrote: >> >> I'm attempting to use spawn_opt/3 with a remote node, like this: >> >> >> >> Fun = fun() -> ok end, >> >> {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). >> >> >> >> It fails with: >> >> >> >> {badarg, >> >> [{erlang,spawn_opt, >> >> ['imp_server@REDACTED',erlang,apply, >> >> [#Fun,[]], >> >> [link,monitor]], >> >> []} >> >> >> >> Now, the documentation at >> >> http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the >> >> 'monitor' option is not allowed for spawn_opt/5. It says nothing about >> >> spawn_opt/3. >> >> >> >> Looking at the error message, it looks like spawn_opt/3 simply calls >> >> spawn_opt/5. Does this note about 'monitor' being unsupported need to >> >> be in documentation for both functions? >> >> _______________________________________________ >> >> 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 prof3ta@REDACTED Tue Feb 24 08:49:55 2015 From: prof3ta@REDACTED (Roberto Aloi) Date: Tue, 24 Feb 2015 08:49:55 +0100 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug? In-Reply-To: References: Message-ID: I just had a quick look at the relevant source code (maint from GitHub). Indeed, spawn_opt/3 simply calls spawn_opt/5 via erlang:apply/2, so all the limitations of spawn_opt/5 are also valid for spawn_opt/3. See: https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2405 Note that when you use node() as the first argument, the code path is different and spawn_opt/2 is called instead, so you can use 'monitor' there: https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2403 Interesting how you can still use a tuple-fun in spawn_opt/X. I thought tuple funs were removed in R16. https://github.com/erlang/otp/blob/121b920ed5a729e69e21d8869d554d736c10f427/erts/preloaded/src/erlang.erl#L2407 Regarding execution of funs in remote nodes, here is a nice reading: http://www.javalimit.com/2010/05/passing-funs-to-other-erlang-nodes.html Roberto On 23 February 2015 at 16:17, Roger Lipscombe wrote: > I'm attempting to use spawn_opt/3 with a remote node, like this: > > Fun = fun() -> ok end, > {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). > > It fails with: > > {badarg, > [{erlang,spawn_opt, > ['imp_server@REDACTED',erlang,apply, > [#Fun,[]], > [link,monitor]], > []} > > Now, the documentation at > http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the > 'monitor' option is not allowed for spawn_opt/5. It says nothing about > spawn_opt/3. > > Looking at the error message, it looks like spawn_opt/3 simply calls > spawn_opt/5. Does this note about 'monitor' being unsupported need to > be in documentation for both functions? > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Roberto Aloi --- Website: http://roberto-aloi.com Twitter: @robertoaloi -------------- next part -------------- An HTML attachment was scrubbed... URL: From kennethlakin@REDACTED Tue Feb 24 07:34:43 2015 From: kennethlakin@REDACTED (Kenneth Lakin) Date: Mon, 23 Feb 2015 22:34:43 -0800 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. How to monitor a remote process? Message-ID: <54EC1B83.6050502@gmail.com> Roger Lipscombe asks: > How do I monitor a process that I spawn on a remote node? Some searching pulls up this message from a similar thread: http://erlang.org/pipermail/erlang-questions/2014-March/078380.html and this reply: http://erlang.org/pipermail/erlang-questions/2014-March/078395.html I *think* that that thread says that monitoring of remote processes is not supported by the distribution protocol. I probably seriously misunderstand what's going on, but it sort of looks like this program indicates that you *can* monitor remote processes: Fun = fun() -> timer:sleep(timer:seconds(5)), io:format("Hello from ~p~n", [node()]) end, Pid = spawn_opt(one@REDACTED, Fun, [link]), monitor(process, Pid), timer:sleep(timer:seconds(5+1)), flush(). Hello from one@REDACTED Shell got {'DOWN',#Ref<0.0.0.452>,process,<7323.94.0>,normal} ok Again. I'm probably deeply confused here. -Kenneth Lakin PS: Apologies for breaking threading. I just joined the list. (And, apologies to the moderator for the earlier half-composed email!) From andrea.peruffo1982@REDACTED Tue Feb 24 09:40:26 2015 From: andrea.peruffo1982@REDACTED (Andrea Peruffo) Date: Tue, 24 Feb 2015 09:40:26 +0100 Subject: [erlang-questions] Why so slow kmeans implementation Message-ID: This: https://github.com/andreaferretti/kmeans is a benchmark of different languages on a kmeans clustering algo. I made an implementation of it but is terribly slow... A question is about the data structure "dict" I used, is that the proper use case or there is anything better? I have checked with "ets" but looks even slower... Is there anything wrong with the provided implementation? Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From roger@REDACTED Tue Feb 24 10:47:54 2015 From: roger@REDACTED (Roger Lipscombe) Date: Tue, 24 Feb 2015 09:47:54 +0000 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. Documentation bug? In-Reply-To: References: <54EB888F.3040504@bestmx.net> <0E00F097-DDB9-48F9-826A-622BA605983B@vailsys.com> Message-ID: On 23 February 2015 at 23:53, Robert Virding wrote: > The implication is that as it does not work with spawn_opt/5 which spawns a > process on another node then it will also not work for spawn_opt/3 which > does the same thing. Whether you give a fun or Mod,Fun,Args is irrelevant > here. Sure. My point is that the documentation for spawn_opt/3 says "Otherwise works like spawn_opt/4". The documentation for spawn_opt/4 then proceeds to list 'monitor' as one of the options. It's only the documentation for spawn_opt/5 that says that 'monitor' won't work. Hence: the documentation could be clearer. > Another reason for getting the badarg is the fun. To pass and call funs on > other nodes requires exactly the same version of the module in which the fun > is defined, in this case erl_eval. An easy way to test this is to just try > and spawn the fun on the other node with spawn/2. If that works then this is > not the problem. That's not my problem, though it is useful to know. Both nodes are running R16B03-1. Removing 'monitor' from the call to spawn_opt works fine, except that I can't monitor the process. For which, see my other email. From dmkolesnikov@REDACTED Tue Feb 24 10:52:05 2015 From: dmkolesnikov@REDACTED (Dmitry Kolesnikov) Date: Tue, 24 Feb 2015 11:52:05 +0200 Subject: [erlang-questions] Why so slow kmeans implementation In-Reply-To: References: Message-ID: <8E8413F1-139E-4A0E-A88A-CC899F525B0B@gmail.com> Hello, dict is not a fastest data structure structure, ets out performs it by level of magnitude. if you have an issue with "ets performance? then you are doing something wrong. Personally, I prefer to use gb_trees, rbtree or binary-search tree instead of dict. Could you share your test data set for kmean? We can look deeply where the issue is. Best Regards, Dmitry > On 24 Feb 2015, at 10:40, Andrea Peruffo wrote: > > This: > https://github.com/andreaferretti/kmeans > is a benchmark of different languages on a kmeans clustering algo. > > I made an implementation of it but is terribly slow... > > A question is about the data structure "dict" I used, is that the proper use case or there is anything better? > I have checked with "ets" but looks even slower... > > Is there anything wrong with the provided implementation? > > Thanks in advance. > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From bjorn@REDACTED Tue Feb 24 10:53:35 2015 From: bjorn@REDACTED (=?UTF-8?Q?Bj=C3=B6rn_Gustavsson?=) Date: Tue, 24 Feb 2015 10:53:35 +0100 Subject: [erlang-questions] Why so slow kmeans implementation In-Reply-To: References: Message-ID: On Tue, Feb 24, 2015 at 9:40 AM, Andrea Peruffo wrote: > This: > https://github.com/andreaferretti/kmeans > is a benchmark of different languages on a kmeans clustering algo. > > I made an implementation of it but is terribly slow... > > A question is about the data structure "dict" I used, is that the proper use > case or there is anything better? > I have checked with "ets" but looks even slower... > Using sofs was 10 times faster on my computer: groupBy(L, Fn) -> TableId = groupBy(L, Fn, []), values(TableId). values([]) -> []; values([{_, V} | T]) -> [V | values(T)]. groupBy([H|T], Fn, Acc) -> Pair = {erlang:phash2(Fn(H)),H}, groupBy(T, Fn, [Pair|Acc]); groupBy([], _, Acc) -> L0 = sofs:relation(Acc), L = sofs:relation_to_family(L0), sofs:to_external(L). https://github.com/andreaferretti/kmeans/pull/12 /Bjorn -- Bj?rn Gustavsson, Erlang/OTP, Ericsson AB From ingela.andin@REDACTED Tue Feb 24 10:59:00 2015 From: ingela.andin@REDACTED (Ingela Andin) Date: Tue, 24 Feb 2015 10:59:00 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> Message-ID: Hi! Did you try observing your system with the observer application? You should be able to get much better information of what Erlang processes consume a lot of memory and why. Regards Ingela Erlang/OTP Team - Ericsson AB 2015-02-20 20:19 GMT+01:00 Roberto Ostinelli : > As an addendum: I apologise because this cannot be clearly seen in the > charts (I forgot to "humanise" the axis), but we're talking about a steady > RAM usage of 4.5GB without SSL, in comparison to blowing up a node with > 30GB with SSL. > > Best, > r. > > On Fri, Feb 20, 2015 at 3:11 PM, Roberto Ostinelli > wrote: > >> Dear List, >> Given the amount of answers I got in this post, I want to follow up and >> give some additional information. >> >> After struggling for quite a while, I just did a comparison between using >> SSL connections vs standard TCP connections. >> The results are quite impressive. >> >> This is the diagram of memory evolution for a system under load, with SSL: >> https://cldup.com/cNOc8hS004-2000x2000.png >> >> This is the same system, but without SSL: >> https://cldup.com/sx3RrdMR8o-3000x3000.png >> >> You can clearly see that using standard TCP connections the system is >> extremely stable. >> Using SSL connections, on the other hand, results in RAM memory having >> very erratic behavior that ends up blowing up the node. >> >> Not sure what to do with this information, except that I'm going to use a >> SSL termination (HAProxy or ELB) and have my Erlang node run without SSL. >> >> If anyone is curious just ping me. >> >> Best, >> r. >> >> >> >> >> >> On Wed, Jan 28, 2015 at 8:09 PM, Roberto Ostinelli < >> roberto.ostinelli@REDACTED> wrote: >> >>> That's a valid point, and I can clarify. >>> >>> During the first phase, all the long lived connections are made. During >>> the second phase, newly-created short lived connections send messages to >>> the long lived ones. >>> >>> The long lived connection are all connected when the first memory >>> increase phase ends, which is when the short-lived connections start >>> sending messages. >>> >>> What is unclear to me is why the second memory increase phase happens >>> quite some time after these short lived processes have started sending >>> messages. >>> >>> >>> > On 28/gen/2015, at 20:02, Anton Lebedevich wrote: >>> > >>> > The graph looks really weird for me assuming that the load applied to >>> > the system is stable. Why does it go down for a short time and then >>> > jumps higher than it was? >>> >> >> > > _______________________________________________ > 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 Feb 24 11:36:13 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Tue, 24 Feb 2015 11:36:13 +0100 Subject: [erlang-questions] Why so slow kmeans implementation In-Reply-To: References: Message-ID: <54EC541D.9070401@ninenines.eu> On 02/24/2015 10:53 AM, Bj?rn Gustavsson wrote: > On Tue, Feb 24, 2015 at 9:40 AM, Andrea Peruffo > wrote: >> This: >> https://github.com/andreaferretti/kmeans >> is a benchmark of different languages on a kmeans clustering algo. >> >> I made an implementation of it but is terribly slow... >> >> A question is about the data structure "dict" I used, is that the proper use >> case or there is anything better? >> I have checked with "ets" but looks even slower... >> > > Using sofs was 10 times faster on my computer: If only a kind soul could improve the sofs documentation so it is understandable by lesser human beings... :-) -- Lo?c Hoguin http://ninenines.eu From vychodil.hynek@REDACTED Tue Feb 24 15:04:48 2015 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 24 Feb 2015 15:04:48 +0100 Subject: [erlang-questions] Why so slow kmeans implementation In-Reply-To: <54EC541D.9070401@ninenines.eu> References: <54EC541D.9070401@ninenines.eu> Message-ID: I second that. BTW the process dictionary version is 50 times faster on mine computer. https://github.com/andreaferretti/kmeans/pull/13 Anyway I would definitely not use Erlang for this sort of task in the production. I would write NIF or use port or C-node for this sort of task. On Tue, Feb 24, 2015 at 11:36 AM, Lo?c Hoguin wrote: > On 02/24/2015 10:53 AM, Bj?rn Gustavsson wrote: > >> On Tue, Feb 24, 2015 at 9:40 AM, Andrea Peruffo >> wrote: >> >>> This: >>> https://github.com/andreaferretti/kmeans >>> is a benchmark of different languages on a kmeans clustering algo. >>> >>> I made an implementation of it but is terribly slow... >>> >>> A question is about the data structure "dict" I used, is that the proper >>> use >>> case or there is anything better? >>> I have checked with "ets" but looks even slower... >>> >>> >> Using sofs was 10 times faster on my computer: >> > > If only a kind soul could improve the sofs documentation so it is > understandable by lesser human beings... :-) > > -- > Lo?c Hoguin > http://ninenines.eu > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From cole.fichter@REDACTED Tue Feb 24 16:37:38 2015 From: cole.fichter@REDACTED (Cole Fichter) Date: Tue, 24 Feb 2015 08:37:38 -0700 Subject: [erlang-questions] What does it mean when an evaluated expression is a list that contains the pipe character? Message-ID: I came across the example: > [1,2|3]. [1,2|3] I understand that the pipe character, |, can be used to append an item to the head of the list or to pop an item off the list in a pattern match. But what exactly is happening in the example above? Why does the evaluated expression still contain the pipe? My best guess is that the final expression results in a match specification that could be used in a pattern match. However, that seems strange too because if so, we'd be popping two items off the list, which should be illegal. Can someone shed some light? Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From gguthrie@REDACTED Tue Feb 24 16:52:16 2015 From: gguthrie@REDACTED (Gordon Guthrie) Date: Tue, 24 Feb 2015 15:52:16 +0000 Subject: [erlang-questions] What does it mean when an evaluated expression is a list that contains the pipe character? In-Reply-To: References: Message-ID: Cole It?s an improper list. A proper list ends with a tail of []. So to make a proper list you would do: > [1, 2 | [3]]. [1, 2, 3]. (This has an implied final cell of an empty list) Gordon > Le 24 f?vr. 2015 ? 15:37, Cole Fichter a ?crit : > > I came across the example: > > > [1,2|3]. > [1,2|3] > > I understand that the pipe character, |, can be used to append an item to the head of the list or to pop an item off the list in a pattern match. > > But what exactly is happening in the example above? Why does the evaluated expression still contain the pipe? > > My best guess is that the final expression results in a match specification that could be used in a pattern match. However, that seems strange too because if so, we'd be popping two items off the list, which should be illegal. > > Can someone shed some light? > > Thanks! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions From roberto@REDACTED Tue Feb 24 16:52:18 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Tue, 24 Feb 2015 16:52:18 +0100 Subject: [erlang-questions] Force re-resolve of DNS Message-ID: Dear List, I'm currently testing a system behind Amazon's ELB. >From their documentation: "If clients do not re-resolve the DNS at least once per minute, then the new resources Elastic Load Balancing adds to DNS will not be used by clients. This can mean that clients continue to overwhelm a small portion of the allocated Elastic Load Balancing resources, while overall Elastic Load Balancing is not being heavily utilized". I therefore need to ensure my clients re-resolve the DNS every minute or so. Is there a way to do so? I couldn't find anything in inet_res. Thank you, r. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gguthrie@REDACTED Tue Feb 24 16:53:21 2015 From: gguthrie@REDACTED (Gordon Guthrie) Date: Tue, 24 Feb 2015 15:53:21 +0000 Subject: [erlang-questions] What does it mean when an evaluated expression is a list that contains the pipe character? In-Reply-To: References: Message-ID: C In case you are uncertain as to what that means - here is a wee primer: http://stackoverflow.com/questions/1919097/functional-programming-what-is-an-improper-list G > Le 24 f?vr. 2015 ? 15:37, Cole Fichter a ?crit : > > I came across the example: > > > [1,2|3]. > [1,2|3] > > I understand that the pipe character, |, can be used to append an item to the head of the list or to pop an item off the list in a pattern match. > > But what exactly is happening in the example above? Why does the evaluated expression still contain the pipe? > > My best guess is that the final expression results in a match specification that could be used in a pattern match. However, that seems strange too because if so, we'd be popping two items off the list, which should be illegal. > > Can someone shed some light? > > Thanks! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions -------------- next part -------------- An HTML attachment was scrubbed... URL: From zxq9@REDACTED Tue Feb 24 16:53:01 2015 From: zxq9@REDACTED (zxq9) Date: Wed, 25 Feb 2015 00:53:01 +0900 Subject: [erlang-questions] What does it mean when an evaluated expression is a list that contains the pipe character? In-Reply-To: References: Message-ID: <3370477.KmV57vO9D0@changa> On 2015?2?24? ??? 08:37:38 Cole Fichter wrote: > I came across the example: > > [1,2|3]. > > [1,2|3] > > I understand that the pipe character, |, can be used to append an item to > the head of the list or to pop an item off the list in a pattern match. > > But what exactly is happening in the example above? Why does the evaluated > expression still contain the pipe? > > My best guess is that the final expression results in a match specification > that could be used in a pattern match. However, that seems strange too > because if so, we'd be popping two items off the list, which should be > illegal. > > Can someone shed some light? It is entirely acceptable to match an arbitrary number of items off the top of a list, provided there are at least as many in the list: 1> SomeList = [1, 2, 3, 4, 5, 6]. [1,2,3,4,5,6] 2> [A, B, C | Rest] = SomeList. [1,2,3,4,5,6] 3> A. 1 4> B. 2 5> C. 3 6> Rest. [4,5,6] Profoundly useful in some cases. -Craig From zxq9@REDACTED Tue Feb 24 16:57:34 2015 From: zxq9@REDACTED (zxq9) Date: Wed, 25 Feb 2015 00:57:34 +0900 Subject: [erlang-questions] What does it mean when an evaluated expression is a list that contains the pipe character? In-Reply-To: <3370477.KmV57vO9D0@changa> References: <3370477.KmV57vO9D0@changa> Message-ID: <4268020.m5iGSQ1u0I@changa> On 2015?2?25? ??? 00:53:01 zxq9 wrote: > On 2015?2?24? ??? 08:37:38 Cole Fichter wrote: > > I came across the example: > > > [1,2|3]. > > > > [1,2|3] > > > > I understand that the pipe character, |, can be used to append an item to > > the head of the list or to pop an item off the list in a pattern match. > > > > But what exactly is happening in the example above? Why does the evaluated > > expression still contain the pipe? > > > > My best guess is that the final expression results in a match > > specification > > that could be used in a pattern match. However, that seems strange too > > because if so, we'd be popping two items off the list, which should be > > illegal. > > > > Can someone shed some light? > > It is entirely acceptable to match an arbitrary number of items off the top > of a list, provided there are at least as many in the list: > > 1> SomeList = [1, 2, 3, 4, 5, 6]. > [1,2,3,4,5,6] > 2> [A, B, C | Rest] = SomeList. > [1,2,3,4,5,6] > 3> A. > 1 > 4> B. > 2 > 5> C. > 3 > 6> Rest. > [4,5,6] As an addendum, since someone mentioned improper lists... 7> L = [1,2,3]. [1,2,3] 8> [1, 2 | 3] = L. ** exception error: no match of right hand side value [1,2,3] 9> [1, 2 | [3]] = L. [1,2,3] Pay close attention to those last two... From cole.fichter@REDACTED Tue Feb 24 17:10:27 2015 From: cole.fichter@REDACTED (Cole Fichter) Date: Tue, 24 Feb 2015 09:10:27 -0700 Subject: [erlang-questions] What does it mean when an evaluated expression is a list that contains the pipe character? In-Reply-To: References: Message-ID: Ah, ok! That SO post is amazing. Thanks for the quick reply. On 24 February 2015 at 08:53, Gordon Guthrie wrote: > C > > In case you are uncertain as to what that means - here is a wee primer: > > > http://stackoverflow.com/questions/1919097/functional-programming-what-is-an-improper-list > > G > > Le 24 f?vr. 2015 ? 15:37, Cole Fichter a ?crit : > > I came across the example: > > > [1,2|3]. > [1,2|3] > > I understand that the pipe character, |, can be used to append an item to > the head of the list or to pop an item off the list in a pattern match. > > But what exactly is happening in the example above? Why does the evaluated > expression still contain the pipe? > > My best guess is that the final expression results in a match > specification that could be used in a pattern match. However, that seems > strange too because if so, we'd be popping two items off the list, which > should be illegal. > > Can someone shed some light? > > Thanks! > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eranga.erl@REDACTED Tue Feb 24 17:20:56 2015 From: eranga.erl@REDACTED (Eranga Udesh) Date: Tue, 24 Feb 2015 21:50:56 +0530 Subject: [erlang-questions] [ANN] NkBASE released In-Reply-To: References: Message-ID: Interesting... congratulations. Will give it a try. Cheers, - Eranga On Mon, Feb 23, 2015 at 11:54 PM, Carlos Gonz?lez Florido < carlosj.gf@REDACTED> wrote: > Hello Erlangers, > > I'm very happy to announce that we have released the first version of > NkBASE, a distributed, highly available key-value database designed to be > integrated into riak_core based Erlang applications. NkBASE is one of the > core pieces of the upcoming Nekso's Software Defined Data Center Platform, > NetComposer. > > NkBASE has some interesting features: > > - Highly available, allowing read and write operations even in case of > node failures. > - Operation friendly. Nodes can be added and removed on the fly. > - Scalable from three to hundreds of nodes. > - Disk (leveldb) and memory (ets) backends. > - Three simultaneous operation modes: > - Eventually consistent mode using Dotted Version Vectors. > - Strong consistent mode based on using riak_ensemble's multi-paxos. > - Easy to use, self-convergent CRDTs called dmaps. > - Multiple, auto-generated secondary indices, usable in the three > modes. > - Can use any Erlang term as domain, class, key, value, index or index > value. > - Simple, easy to use, utf8 and latin-1 aware query language for > secondary indices. > - Full support for auto-expiration of objects, with configurable > resolution. > > NkBASE has a clean code base, and can be used as a starting point to learn > how to build a distributed Erlang system on top of riak_core, or to test > new backends or replication mechanisms. > > NkBASE heavily relies on the impressive riak_core, riak_dt and > riak_ensemble from Basho. > > Try it at https://github.com/Nekso/nkbase. Comments are very welcomed! > > Carlos Gonzalez > @carlosjgf > https://www.linkedin.com/in/carlosjgf > > > > > _______________________________________________ > 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 Feb 24 17:26:10 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Tue, 24 Feb 2015 17:26:10 +0100 Subject: [erlang-questions] Force re-resolve of DNS In-Reply-To: References: Message-ID: I'm considering using the {cache_refresh, Time}. of inet_cfg: http://www.erlang.org/doc/apps/erts/inet_cfg.html Wouldn't this be a valid option? Best, r. On Tue, Feb 24, 2015 at 4:52 PM, Roberto Ostinelli wrote: > Dear List, > I'm currently testing a system behind Amazon's ELB. > > From their documentation: > > "If clients do not re-resolve the DNS at least once per minute, then the > new resources Elastic Load Balancing adds to DNS will not be used by > clients. This can mean that clients continue to overwhelm a small portion > of the allocated Elastic Load Balancing resources, while overall Elastic > Load Balancing is not being heavily utilized". > > I therefore need to ensure my clients re-resolve the DNS every minute or > so. Is there a way to do so? I couldn't find anything in inet_res. > > Thank you, > r. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tthread@REDACTED Tue Feb 24 18:11:54 2015 From: tthread@REDACTED (Ilya Shcherbak) Date: Wed, 25 Feb 2015 00:11:54 +0700 Subject: [erlang-questions] What does it mean when an evaluated expression is a list that contains the pipe character? In-Reply-To: References: Message-ID: For better understanding Erlang lists will be better address to Lisp lists. Actually there r no lists at all. There are only cells linked together. It'll be good to take parallel line with Lisp: cons-cell consist left and right value: (1 . 2) - 1 is left value, 2 - right one > (cons 1 2) <---- (1 . 2) left value named 'car' and right - 'cdr'. 'cdr' value can be a link to another cons-cell. for construct list in Lisp u should bring all cells together via 'cdr' links. the tail 'cdr' element linked with 'nil'. it looks like this: >(cons 1 (cons 2 (cons 3 nil))) <---- (1, 2, 3) the same thing in Erlang: there is a cons-cell: > [1 | 2]. <---- [1 | 2]. u can compose Erlang list in Lisp style: > [1 | [2 | [3 | []]]]. <---- [1,2,3]. Erlang list - is a sequence of linked cons-cells also. tail cell should point to []. (like 'nil' in Lisp). [1, 2 | 3] - incorrect Erlang list cuz it contains cell which 'cdr' element isn't link. [1, 2 | [3 | []]] or [1, 2 | [3]] - correct Erlang list cuz each 'cdr' element in each cell shows to another cell. ' | ' operator doesn't applied to lists. it works with "cells" and values. also u can compare list with linked-list in C but it's incorrect cuz Erlang list can consist elements with different types. 2015-02-24 21:37 GMT+06:00 Cole Fichter : > I came across the example: > > > [1,2|3]. > [1,2|3] > > I understand that the pipe character, |, can be used to append an item to > the head of the list or to pop an item off the list in a pattern match. > > But what exactly is happening in the example above? Why does the evaluated > expression still contain the pipe? > > My best guess is that the final expression results in a match > specification that could be used in a pattern match. However, that seems > strange too because if so, we'd be popping two items off the list, which > should be illegal. > > Can someone shed some light? > > Thanks! > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vychodil.hynek@REDACTED Tue Feb 24 18:28:02 2015 From: vychodil.hynek@REDACTED (Hynek Vychodil) Date: Tue, 24 Feb 2015 18:28:02 +0100 Subject: [erlang-questions] Why so slow kmeans implementation In-Reply-To: References: Message-ID: The main problem is the behaviour of dict:append/3. From documentation: For example append/3 could be defined as: append(Key, Val, D) -> update(Key, fun (Old) -> Old ++ [Val] end, [Val], D). dict module is implemented in pure erlang which means Old ++ [Val] is what exactly happens behind. When Old part is growing it becomes the problem due its quadratic complexity. The solution is use dict:update/4 in the way: preppend(Key, Val, D) -> dict:update(Key, fun (Old) -> [Val|Old] end, [Val], D). With this fix, it is around 24 times faster on mine computer. https://github.com/andreaferretti/kmeans/pull/14 Faster process dictionary version is available at https://github.com/pichi/kmeans/tree/proc_dict It is not good practice but can be an inspiration how to write fast code when there is not other option like NIF, C-port or C-node. On Tue, Feb 24, 2015 at 9:40 AM, Andrea Peruffo < andrea.peruffo1982@REDACTED> wrote: > This: > https://github.com/andreaferretti/kmeans > is a benchmark of different languages on a kmeans clustering algo. > > I made an implementation of it but is terribly slow... > > A question is about the data structure "dict" I used, is that the proper > use case or there is anything better? > I have checked with "ets" but looks even slower... > > Is there anything wrong with the provided implementation? > > Thanks in advance. > > > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nem@REDACTED Tue Feb 24 20:00:48 2015 From: nem@REDACTED (Geoff Cant) Date: Tue, 24 Feb 2015 11:00:48 -0800 Subject: [erlang-questions] Force re-resolve of DNS In-Reply-To: References: Message-ID: <41B2454C-44F7-4D46-9008-A47AC9A8F448@erlang.geek.nz> Looks like {cache_size, 0}. might be an option too. That said, ELBs don't change their IPs all that often. It takes ~10mins for scale events to happen (increase in requests before the ELB adds more nodes), so I wouldn't worry too much about getting dns results to expire every minute. I think it's more important that after resolving, if you connect and get some kind of error (connection refused, or an invalid ssl cert, or some other response that shouldn't be possible from your ELB) that your client re-resolves DNS before reconnecting. (i.e. the failure you're protecting against is a stale DNS result that's leading you to someone else's ELB) Cheers, -G > On 2015-02-24, at 08:26 , Roberto Ostinelli wrote: > > I'm considering using the {cache_refresh, Time}. of inet_cfg: > http://www.erlang.org/doc/apps/erts/inet_cfg.html > > Wouldn't this be a valid option? > > Best, > r. > > On Tue, Feb 24, 2015 at 4:52 PM, Roberto Ostinelli wrote: > Dear List, > I'm currently testing a system behind Amazon's ELB. > > From their documentation: > > "If clients do not re-resolve the DNS at least once per minute, then the new resources Elastic Load Balancing adds to DNS will not be used by clients. This can mean that clients continue to overwhelm a small portion of the allocated Elastic Load Balancing resources, while overall Elastic Load Balancing is not being heavily utilized". > > I therefore need to ensure my clients re-resolve the DNS every minute or so. Is there a way to do so? I couldn't find anything in inet_res. > > Thank you, > r. From harit.subscriptions@REDACTED Tue Feb 24 23:00:28 2015 From: harit.subscriptions@REDACTED (Harit Himanshu) Date: Tue, 24 Feb 2015 14:00:28 -0800 Subject: [erlang-questions] How to calculate series expansion e^x Message-ID: I am trying to learn Functional Programming and Erlang by practicing problems available online. One question where I don't know about solving it is The series expansion of ex is given by: 1 + x + x2/2! + x3/3! + x4/4! + ....... Evaluate e^x for given values of x, by using the above expansion for the first 10 terms. The problem statement could be found here Can someone guide me how this could be achieved in Erlang? Thanks a lot + Harit Himanshu -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok@REDACTED Wed Feb 25 01:14:56 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 25 Feb 2015 13:14:56 +1300 Subject: [erlang-questions] What does it mean when an evaluated expression is a list that contains the pipe character? In-Reply-To: References: Message-ID: On 25/02/2015, at 4:37 am, Cole Fichter wrote: > > I understand that the pipe character, |, can be used to append an item to the head of the list or to pop an item off the list in a pattern match. Just a point on terminology: [x] ++ [y,z] is APPENDING (concatenating two lists); [x | [y,z]] is CONSING. > But what exactly is happening in the example above? Why does the evaluated expression still contain the pipe? This goes back to about 1959. There is no spoon. Sorry, there are no lists. THERE ARE ONLY PAIRS. Lisp : (car . cdr) Prolog : [Head | Tail] Erlang : [Head | Tail] There is a convention in Lisp that . () need not be mentioned. There is a convention in Prolog that | [] need not be mentioned. There is a convention in Erlang that | [] need not be mentioned. There is a convention in Lisp that (a . (b . )) abbreviates as (a b . ). There is a convention in Prolog that [a | [b | ]] abbreviates as [a,b | ]. There is a convention in Erlang that [a | [b | ]] abbreviates as [a,b | ]. The so-called "list" [1,2,3] is *really* [1|[2|[3|[]]]]. [1,2,3] is just an abbreviation for convenience. EVERY non-empty list "still contain(s) the pipe". It's just that when the ultimate tail happens to be the empty list, it will not be shown. [1,2|3] is no different in its structure from [1,2|[]], it's just that [1,2|[]] will be DISPLAYED without the |[] part. BUT IT IS STILL THERE. > My best guess is that the final expression results in a match specification that could be used in a pattern match. I'm having difficulty understanding this. There is nothing in the least special about [1,2|3]. It is just a pair whose head is 1 and whose tail is a pair whose head is 2 and whose tail is 3. It's just a boring old plain old data structure. > However, that seems strange too because if so, we'd be popping two items off the list, which should be illegal. There is no such thing as "popping". You cannot change the list [1,2,3] any more than you can change the number 137. You can *recognise* that it has a certain form and *extract* information from it, but you can't *change* it. The pattern match [A,B|Rest] = [1,2,3] is perfectly legal and will bind A = 1, B = 2, Rest = [3]. The pattern match [X,Y|More] = [1,2|3] is also perfectly legal and will bind X = 1, Y = 2, More = 3. Why would you think that "popping" two items off a list that _has_ two items should be illegal? It all makes sense when you realise that there are no lists, only pairs. From ok@REDACTED Wed Feb 25 04:27:58 2015 From: ok@REDACTED (Richard A. O'Keefe) Date: Wed, 25 Feb 2015 16:27:58 +1300 Subject: [erlang-questions] How to calculate series expansion e^x In-Reply-To: References: Message-ID: <2E28711F-E72D-4E90-A708-CB2782B958FF@cs.otago.ac.nz> On 25/02/2015, at 11:00 am, Harit Himanshu wrote: > I am trying to learn Functional Programming and Erlang by practicing problems available online. > > One question where I don't know about solving it is > > The series expansion of ex is given by: > > 1 + x + x2/2! + x3/3! + x4/4! + ....... > > Evaluate e^x for given values of x, by using the above expansion for the first 10 terms. > > > The problem statement could be found here > > Can someone guide me how this could be achieved in Erlang? The first 10 terms of exp(X) are X X^2 X^3 X^9 1 + --- + --- + --- + ... + --- 1 2 6 9! This is a polynomial. We can evaluate it cheaply using Horner's Rule. Any time you have a polynomial to evaluate, you should think about using Horner's Rule. X / X / X / X \ \ \ 1 + --- * | 1 + --- * | 1 + --- * ... | 1 + --- | ...| | 1 \ 2 \ 3 \ 9 / / / We can see a building block here: 1 + (X/n)*Rest. So let's make a function for the building block: step(X, N, Rest) when is_float(X), is_float(N), is_float(Rest) -> 1.0 + (X/N)*Rest. There are 9 steps, which is small enough to do by hand: (NINE steps to get TEN terms. I hope that's clear.) exp(X) when is_float(X) -> step(X, 1.0, step(X, 2.0, step(X, 3.0, step(X, 4.0, step(X, 5.0, step(X, 6.0, step(X, 7.0, step(X, 8.0, step(X, 9.0, 1.0))))))))). I should point out that this is a lousy way to compute exp(X) for abs(X) "large". Waving hands vaguely, you want X^10/10! "small". The relative error for X = 1.0 is -1.1e-7, for X = 2.0 is -4.6e-5, and for X = 4.0 is a scary -0.0081. One technique that's used in cases like this is RANGE REDUCTION. e^x = 2^(1.442695... * x). To begin, scale x by log of e to the base 2, and separate that into an integer part N and a fraction part F. e^x is then 2^(N+F) = 2^N*2^F. Since F is "small", we can use something like this polynomial. And then we can use the equivalent of C's ldexp() to handle the 2^N* part. Or we could if Erlang _had_ an equivalent of ldexp(). You don't really need the is_float/1 tests; I put them in so that the compiler could generate better native code. From davidnwelton@REDACTED Wed Feb 25 11:39:18 2015 From: davidnwelton@REDACTED (David Welton) Date: Wed, 25 Feb 2015 11:39:18 +0100 Subject: [erlang-questions] rpc, group_leader, and logging errors Message-ID: Hi, I opened a pull request against OTP, but then closed it when I realized it may not do what I want: https://github.com/erlang/otp/pull/629 The problem is that we have C and Java nodes that occasionally send bad rpc's. It'd be very nice to be able to log/diagnose that on the Erlang system rather than relying on the Java system to receive the bad rpc message, and then send it back to Erlang again or something similarly circuitous. Ideas on how to best accomplish this? -- David N. Welton http://www.welton.it/davidw/ http://www.dedasys.com/ From viktor@REDACTED Wed Feb 25 14:47:20 2015 From: viktor@REDACTED (=?ISO-8859-1?Q?Viktor_S=F6derqvist?=) Date: Wed, 25 Feb 2015 14:47:20 +0100 Subject: [erlang-questions] [ANN] "MySQL/OTP" - rewritten MySQL driver Message-ID: Hello Erlang users! Due to the known problems with Emysql, especially the lack of solid transaction handling, we have written a MySQL driver from scratch. The code structure of Emysql wasn't good enough to build upon and since we also wanted to change the API a little, it made sense to write a new driver. As the name suggests, that we wanted to make it more "OTP-ish". Github project page: https://github.com/mysql-otp/mysql-otp Notable Features: * A connection is a gen_server which makes it easy to use https://github.com/devinus/poolboy, https://github.com/seth/pooler or any other supervisor based connection pooling mechanism for those who need connection pooling. * Mnesia style transactions that can be *nested* (implemented using SQL savepoints) and are automatically *retried* when deadlocks are detected, just like Mnesia transactions. * Simple API without records. More information is available on the github project page and in the corresponding github wiki. Since a few weeks, we're using this driver in production in a hosted e-commerce platform powering a few thousand web stores, but in the interest of all users of Erlang + MySQL we have created a separate github organisations for this project to keep it independent. I would consider this driver fairly stable already. Also note that we're not in any way against the Emysql project, which AFAIK is still in need of a maintainer. For new projects however, I'd recommend MySQL/OTP. Viktor S?derqvist From gumm@REDACTED Wed Feb 25 15:39:16 2015 From: gumm@REDACTED (Jesse Gumm) Date: Wed, 25 Feb 2015 08:39:16 -0600 Subject: [erlang-questions] [ANN] "MySQL/OTP" - rewritten MySQL driver In-Reply-To: References: Message-ID: Very cool! Congrats on the release! -- Jesse Gumm Owner, Sigma Star Systems 414.940.4866 || sigma-star.com || @jessegumm On Feb 25, 2015 7:47 AM, "Viktor S?derqvist" wrote: > Hello Erlang users! > > Due to the known problems with Emysql, especially the lack of solid > transaction handling, we have written a MySQL driver from scratch. The > code structure of Emysql wasn't good enough to build upon and since we > also wanted to change the API a little, it made sense to write a new > driver. As the name suggests, that we wanted to make it more > "OTP-ish". > > Github project page: > > https://github.com/mysql-otp/mysql-otp > > Notable Features: > > * A connection is a gen_server which makes it easy to use > https://github.com/devinus/poolboy, https://github.com/seth/pooler or > any other supervisor based connection pooling mechanism for those who > need connection pooling. > * Mnesia style transactions that can be *nested* (implemented using > SQL savepoints) and are automatically *retried* when deadlocks are > detected, just like Mnesia transactions. > * Simple API without records. > > More information is available on the github project page and in the > corresponding github wiki. > > Since a few weeks, we're using this driver in production in a hosted > e-commerce platform powering a few thousand web stores, but in the > interest of all users of Erlang + MySQL we have created a separate > github organisations for this project to keep it independent. I would > consider this driver fairly stable already. > > Also note that we're not in any way against the Emysql project, which > AFAIK is still in need of a maintainer. For new projects however, I'd > recommend MySQL/OTP. > > Viktor S?derqvist > _______________________________________________ > 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 Wed Feb 25 16:31:27 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Wed, 25 Feb 2015 16:31:27 +0100 Subject: [erlang-questions] Force re-resolve of DNS In-Reply-To: <41B2454C-44F7-4D46-9008-A47AC9A8F448@erlang.geek.nz> References: <41B2454C-44F7-4D46-9008-A47AC9A8F448@erlang.geek.nz> Message-ID: Thank you Geoff, I'm actually seeing errors way before the 10 minutes. To put it in perspective: without ELB I can connect 180,000 long-term connections in 1 minute. With ELB, I get up to 7,000. There's the whole "pre-warming" thing so I think this might be related: though I've been bashing it repeatedly and it really doesn't change anything. So I'm trying to isolate why this isn't working as expected behind an ELB. Any thought from anyone who has used ELB in their life? Better if Erlang-related obviously, this started as an Erlang question after all ;) Best, r. On Tue, Feb 24, 2015 at 8:00 PM, Geoff Cant wrote: > Looks like {cache_size, 0}. might be an option too. > > That said, ELBs don't change their IPs all that often. It takes ~10mins > for scale events to happen (increase in requests before the ELB adds more > nodes), so I wouldn't worry too much about getting dns results to expire > every minute. I think it's more important that after resolving, if you > connect and get some kind of error (connection refused, or an invalid ssl > cert, or some other response that shouldn't be possible from your ELB) that > your client re-resolves DNS before reconnecting. (i.e. the failure you're > protecting against is a stale DNS result that's leading you to someone > else's ELB) > > Cheers, > -G > > > On 2015-02-24, at 08:26 , Roberto Ostinelli wrote: > > > > I'm considering using the {cache_refresh, Time}. of inet_cfg: > > http://www.erlang.org/doc/apps/erts/inet_cfg.html > > > > Wouldn't this be a valid option? > > > > Best, > > r. > > > > On Tue, Feb 24, 2015 at 4:52 PM, Roberto Ostinelli > wrote: > > Dear List, > > I'm currently testing a system behind Amazon's ELB. > > > > From their documentation: > > > > "If clients do not re-resolve the DNS at least once per minute, then the > new resources Elastic Load Balancing adds to DNS will not be used by > clients. This can mean that clients continue to overwhelm a small portion > of the allocated Elastic Load Balancing resources, while overall Elastic > Load Balancing is not being heavily utilized". > > > > I therefore need to ensure my clients re-resolve the DNS every minute or > so. Is there a way to do so? I couldn't find anything in inet_res. > > > > Thank you, > > r. > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mononcqc@REDACTED Wed Feb 25 16:56:02 2015 From: mononcqc@REDACTED (Fred Hebert) Date: Wed, 25 Feb 2015 10:56:02 -0500 Subject: [erlang-questions] Force re-resolve of DNS In-Reply-To: References: <41B2454C-44F7-4D46-9008-A47AC9A8F448@erlang.geek.nz> Message-ID: The ELB *will* need prewarming, otherwise, only a long sustained period of activity will force it to auto-scale up. I'm not sure what the exact time duration is, but it's far from instantaneous. ELBs can auto-scale to dozens of nodes per AZ but it's usually easier to just try and open a support ticket, ask for prewarming along with the load (or concurrent connections) you expect to need to handle, and their team will help scale it up. On Wed, Feb 25, 2015 at 10:31 AM, Roberto Ostinelli wrote: > Thank you Geoff, > I'm actually seeing errors way before the 10 minutes. > > To put it in perspective: without ELB I can connect 180,000 long-term > connections in 1 minute. > With ELB, I get up to 7,000. > > There's the whole "pre-warming" thing so I think this might be related: > though I've been bashing it repeatedly and it really doesn't change > anything. > So I'm trying to isolate why this isn't working as expected behind an ELB. > > Any thought from anyone who has used ELB in their life? Better if > Erlang-related obviously, this started as an Erlang question after all ;) > > Best, > r. > > On Tue, Feb 24, 2015 at 8:00 PM, Geoff Cant wrote: > >> Looks like {cache_size, 0}. might be an option too. >> >> That said, ELBs don't change their IPs all that often. It takes ~10mins >> for scale events to happen (increase in requests before the ELB adds more >> nodes), so I wouldn't worry too much about getting dns results to expire >> every minute. I think it's more important that after resolving, if you >> connect and get some kind of error (connection refused, or an invalid ssl >> cert, or some other response that shouldn't be possible from your ELB) that >> your client re-resolves DNS before reconnecting. (i.e. the failure you're >> protecting against is a stale DNS result that's leading you to someone >> else's ELB) >> >> Cheers, >> -G >> >> > On 2015-02-24, at 08:26 , Roberto Ostinelli >> wrote: >> > >> > I'm considering using the {cache_refresh, Time}. of inet_cfg: >> > http://www.erlang.org/doc/apps/erts/inet_cfg.html >> > >> > Wouldn't this be a valid option? >> > >> > Best, >> > r. >> > >> > On Tue, Feb 24, 2015 at 4:52 PM, Roberto Ostinelli >> wrote: >> > Dear List, >> > I'm currently testing a system behind Amazon's ELB. >> > >> > From their documentation: >> > >> > "If clients do not re-resolve the DNS at least once per minute, then >> the new resources Elastic Load Balancing adds to DNS will not be used by >> clients. This can mean that clients continue to overwhelm a small portion >> of the allocated Elastic Load Balancing resources, while overall Elastic >> Load Balancing is not being heavily utilized". >> > >> > I therefore need to ensure my clients re-resolve the DNS every minute >> or so. Is there a way to do so? I couldn't find anything in inet_res. >> > >> > Thank you, >> > r. >> >> >> >> > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From felixgallo@REDACTED Wed Feb 25 17:33:29 2015 From: felixgallo@REDACTED (Felix Gallo) Date: Wed, 25 Feb 2015 08:33:29 -0800 Subject: [erlang-questions] Force re-resolve of DNS In-Reply-To: References: <41B2454C-44F7-4D46-9008-A47AC9A8F448@erlang.geek.nz> Message-ID: I responded to Roberto privately about this at a bit more length, but in summary: my experiences with a large client attempting to use ELB to elastically balance load were a continuous slow motion clown car train wreck, and truly any solution is better; but in particular, haproxy is very stable under load, is radically more configurable than ELB, radically more informative, and you don't have to open a ticket with haproxy in order for it to pretend to work properly. F. On Wed, Feb 25, 2015 at 7:56 AM, Fred Hebert wrote: > The ELB *will* need prewarming, otherwise, only a long sustained period > of activity will force it to auto-scale up. I'm not sure what the exact > time duration is, but it's far from instantaneous. ELBs can auto-scale to > dozens of nodes per AZ but it's usually easier to just try and open a > support ticket, ask for prewarming along with the load (or concurrent > connections) you expect to need to handle, and their team will help scale > it up. > > On Wed, Feb 25, 2015 at 10:31 AM, Roberto Ostinelli > wrote: > >> Thank you Geoff, >> I'm actually seeing errors way before the 10 minutes. >> >> To put it in perspective: without ELB I can connect 180,000 long-term >> connections in 1 minute. >> With ELB, I get up to 7,000. >> >> There's the whole "pre-warming" thing so I think this might be related: >> though I've been bashing it repeatedly and it really doesn't change >> anything. >> So I'm trying to isolate why this isn't working as expected behind an ELB. >> >> Any thought from anyone who has used ELB in their life? Better if >> Erlang-related obviously, this started as an Erlang question after all ;) >> >> Best, >> r. >> >> On Tue, Feb 24, 2015 at 8:00 PM, Geoff Cant wrote: >> >>> Looks like {cache_size, 0}. might be an option too. >>> >>> That said, ELBs don't change their IPs all that often. It takes ~10mins >>> for scale events to happen (increase in requests before the ELB adds more >>> nodes), so I wouldn't worry too much about getting dns results to expire >>> every minute. I think it's more important that after resolving, if you >>> connect and get some kind of error (connection refused, or an invalid ssl >>> cert, or some other response that shouldn't be possible from your ELB) that >>> your client re-resolves DNS before reconnecting. (i.e. the failure you're >>> protecting against is a stale DNS result that's leading you to someone >>> else's ELB) >>> >>> Cheers, >>> -G >>> >>> > On 2015-02-24, at 08:26 , Roberto Ostinelli >>> wrote: >>> > >>> > I'm considering using the {cache_refresh, Time}. of inet_cfg: >>> > http://www.erlang.org/doc/apps/erts/inet_cfg.html >>> > >>> > Wouldn't this be a valid option? >>> > >>> > Best, >>> > r. >>> > >>> > On Tue, Feb 24, 2015 at 4:52 PM, Roberto Ostinelli < >>> roberto@REDACTED> wrote: >>> > Dear List, >>> > I'm currently testing a system behind Amazon's ELB. >>> > >>> > From their documentation: >>> > >>> > "If clients do not re-resolve the DNS at least once per minute, then >>> the new resources Elastic Load Balancing adds to DNS will not be used by >>> clients. This can mean that clients continue to overwhelm a small portion >>> of the allocated Elastic Load Balancing resources, while overall Elastic >>> Load Balancing is not being heavily utilized". >>> > >>> > I therefore need to ensure my clients re-resolve the DNS every minute >>> or so. Is there a way to do so? I couldn't find anything in inet_res. >>> > >>> > Thank you, >>> > r. >>> >>> >>> >>> >> >> _______________________________________________ >> 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 roberto.ostinelli@REDACTED Wed Feb 25 19:49:19 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Wed, 25 Feb 2015 19:49:19 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> Message-ID: <93FF5FD5-B802-4B7E-ACA2-CF717892A3B5@widetag.com> It's the processes handling the ssl sockets. Best, r. > On 24/feb/2015, at 10:59, Ingela Andin wrote: > > Hi! > > Did you try observing your system with the observer application? You should be able to get much better information of what Erlang processes consume a lot of memory and > why. > > > Regards Ingela Erlang/OTP Team - Ericsson AB > > > 2015-02-20 20:19 GMT+01:00 Roberto Ostinelli : >> As an addendum: I apologise because this cannot be clearly seen in the charts (I forgot to "humanise" the axis), but we're talking about a steady RAM usage of 4.5GB without SSL, in comparison to blowing up a node with 30GB with SSL. >> >> Best, >> r. >> >>> On Fri, Feb 20, 2015 at 3:11 PM, Roberto Ostinelli wrote: >>> Dear List, >>> Given the amount of answers I got in this post, I want to follow up and give some additional information. >>> >>> After struggling for quite a while, I just did a comparison between using SSL connections vs standard TCP connections. >>> The results are quite impressive. >>> >>> This is the diagram of memory evolution for a system under load, with SSL: >>> https://cldup.com/cNOc8hS004-2000x2000.png >>> >>> This is the same system, but without SSL: >>> https://cldup.com/sx3RrdMR8o-3000x3000.png >>> >>> You can clearly see that using standard TCP connections the system is extremely stable. >>> Using SSL connections, on the other hand, results in RAM memory having very erratic behavior that ends up blowing up the node. >>> >>> Not sure what to do with this information, except that I'm going to use a SSL termination (HAProxy or ELB) and have my Erlang node run without SSL. >>> >>> If anyone is curious just ping me. >>> >>> Best, >>> r. >>> >>> >>> >>> >>> >>>> On Wed, Jan 28, 2015 at 8:09 PM, Roberto Ostinelli wrote: >>>> That's a valid point, and I can clarify. >>>> >>>> During the first phase, all the long lived connections are made. During the second phase, newly-created short lived connections send messages to the long lived ones. >>>> >>>> The long lived connection are all connected when the first memory increase phase ends, which is when the short-lived connections start sending messages. >>>> >>>> What is unclear to me is why the second memory increase phase happens quite some time after these short lived processes have started sending messages. >>>> >>>> >>>> > On 28/gen/2015, at 20:02, Anton Lebedevich wrote: >>>> > >>>> > The graph looks really weird for me assuming that the load applied to >>>> > the system is stable. Why does it go down for a short time and then >>>> > jumps higher than it was? >> >> >> _______________________________________________ >> erlang-questions mailing list >> erlang-questions@REDACTED >> http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nx@REDACTED Wed Feb 25 20:03:44 2015 From: nx@REDACTED (nx) Date: Wed, 25 Feb 2015 14:03:44 -0500 Subject: [erlang-questions] Supervising a Process that is Dependent on Another Process Message-ID: Is it possible to supervise a process that requires the Pid of another process in its start_link function? I'm not clear on how I can get the supervisor to 1) start a process 2) start another process with the Pid of the first process, then 3) restart both of these if the first process fails and automatically pass in the Pid of the restarted first process to the second process. I may be expecting too much from the supervisor. Any suggestions? Thanks! From eriksoe@REDACTED Wed Feb 25 20:28:54 2015 From: eriksoe@REDACTED (=?UTF-8?Q?Erik_S=C3=B8e_S=C3=B8rensen?=) Date: Wed, 25 Feb 2015 20:28:54 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: <93FF5FD5-B802-4B7E-ACA2-CF717892A3B5@widetag.com> References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> <93FF5FD5-B802-4B7E-ACA2-CF717892A3B5@widetag.com> Message-ID: Are you using the 'hibernate_after' ssl option? It made quite a difference in our application. Den 25/02/2015 19.49 skrev "Roberto Ostinelli" < roberto.ostinelli@REDACTED>: > It's the processes handling the ssl sockets. > > Best, > r. > > > > On 24/feb/2015, at 10:59, Ingela Andin wrote: > > Hi! > > Did you try observing your system with the observer application? You > should be able to get much better information of what Erlang processes > consume a lot of memory and > why. > > > Regards Ingela Erlang/OTP Team - Ericsson AB > > > 2015-02-20 20:19 GMT+01:00 Roberto Ostinelli : > >> As an addendum: I apologise because this cannot be clearly seen in the >> charts (I forgot to "humanise" the axis), but we're talking about a steady >> RAM usage of 4.5GB without SSL, in comparison to blowing up a node with >> 30GB with SSL. >> >> Best, >> r. >> >> On Fri, Feb 20, 2015 at 3:11 PM, Roberto Ostinelli >> wrote: >> >>> Dear List, >>> Given the amount of answers I got in this post, I want to follow up and >>> give some additional information. >>> >>> After struggling for quite a while, I just did a comparison between >>> using SSL connections vs standard TCP connections. >>> The results are quite impressive. >>> >>> This is the diagram of memory evolution for a system under load, with >>> SSL: >>> https://cldup.com/cNOc8hS004-2000x2000.png >>> >>> This is the same system, but without SSL: >>> https://cldup.com/sx3RrdMR8o-3000x3000.png >>> >>> You can clearly see that using standard TCP connections the system is >>> extremely stable. >>> Using SSL connections, on the other hand, results in RAM memory having >>> very erratic behavior that ends up blowing up the node. >>> >>> Not sure what to do with this information, except that I'm going to use >>> a SSL termination (HAProxy or ELB) and have my Erlang node run without SSL. >>> >>> If anyone is curious just ping me. >>> >>> Best, >>> r. >>> >>> >>> >>> >>> >>> On Wed, Jan 28, 2015 at 8:09 PM, Roberto Ostinelli < >>> roberto.ostinelli@REDACTED> wrote: >>> >>>> That's a valid point, and I can clarify. >>>> >>>> During the first phase, all the long lived connections are made. During >>>> the second phase, newly-created short lived connections send messages to >>>> the long lived ones. >>>> >>>> The long lived connection are all connected when the first memory >>>> increase phase ends, which is when the short-lived connections start >>>> sending messages. >>>> >>>> What is unclear to me is why the second memory increase phase happens >>>> quite some time after these short lived processes have started sending >>>> messages. >>>> >>>> >>>> > On 28/gen/2015, at 20:02, Anton Lebedevich wrote: >>>> > >>>> > The graph looks really weird for me assuming that the load applied to >>>> > the system is stable. Why does it go down for a short time and then >>>> > jumps higher than it was? >>>> >>> >>> >> >> _______________________________________________ >> 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 Wed Feb 25 21:01:17 2015 From: max.lapshin@REDACTED (Max Lapshin) Date: Thu, 26 Feb 2015 00:01:17 +0400 Subject: [erlang-questions] [ANN] "MySQL/OTP" - rewritten MySQL driver In-Reply-To: References: Message-ID: Very good! Is there any code that can be shared across mysql / postgres drivers? -------------- next part -------------- An HTML attachment was scrubbed... URL: From richard.youngkin@REDACTED Thu Feb 26 01:36:50 2015 From: richard.youngkin@REDACTED (Youngkin, Rich) Date: Wed, 25 Feb 2015 17:36:50 -0700 Subject: [erlang-questions] Why isn't 'EXIT' message being received/processed? In-Reply-To: References: Message-ID: I have an explanation for why it appears as if an 'EXIT' message isn't received and processed. It seems kind of obvious looking back, but also subtle enough that I don't feel like a complete idiot :) Hopefully this may help someone else who trips over the problem. I'm also interested in feedback, especially concerning some alternatives I describe below for addressing it. So to recap, I have a process that creates a process using spawn_link. This parent process has a receive loop with a clause that matches 'EXIT'. The problem I encountered was that the child's 'EXIT' messages weren't always being received by the parent process before the parent process tried to send a message to the linked child process. In this case the parent process would fail with a "noproc" error (i.e., the child process no longer exists). The cause appears to be the order of messages received in the parent's mailbox. The 'EXIT' message is handled just like any other message in that a process's mailbox behaves like a queue (FIFO). So the 'EXIT' message is placed in the mailbox after any other unprocessed messages. Those messages will be handled before the 'EXIT' message. In my case, one of the prior messages results in sending a message (PID ! Message) to the failed child process before the 'EXIT' message is seen, a simple race condition. I have seen test results that support this theory. Am I correctly characterizing the handling of 'EXIT' messages WRT general mailbox behavior? Since this behavior is non-deterministic my simple approach of handling 'EXIT' messages won't work. Alternatives I'm considering include: 1. Selective receives, but I don't really see this as a robust approach to handling this given the description of this approach in LYSE. LYSE also describes a better approach using min_heap, but this seems like overkill in my case. 2. Handling 'EXIT' messages and backing that up with a try/catch for the race condition. 3. Forget linking altogether and just handle the problem with a try/catch block I'm leaning towards option 3 and I'm interested in other opinions/options. Finally, this seems like a fairly common use case, especially in RabbitMQ applications (where the recommendation is to monitor/link amqp_channel processes). But maybe I'm missing something, or misusing 'EXIT'? Any comments? Thanks, Rich On Tue, Feb 17, 2015 at 3:25 PM, Youngkin, Rich < richard.youngkin@REDACTED> wrote: > Hi, > > I've got an app that spawn_links processes with trap_exit. I'm killing the > linked processes but the monitoring process isn't always receiving the > 'EXIT' message. Here are some code snippets: > > ... > process_flag(trap_exit, true), > link(Connection), > link(Channel), > ... > > loop(State) -> > ... > {'EXIT', What, Reason} -> > do_something_smart(); > > ... > > Connection and Channel are a RabbitMQ connection and channel (although > that's not necessarily important to know). I'm manually running "force > close" on the connection via the RabbitMQ admin interface to trigger the > 'EXIT'. In one case the 'EXIT' message is received and in the other case > it isn't. Here are more code snippets to illustrate this (same loop/1 > function as above): > > loop(#state{channel=Channel, delay_ack= DelayAck} = State) -> > ... > > {#'basic.deliver'{delivery_tag=DeliveryTag}, Content} -> > ... do something with the content > case DelayAck of > true -> > timer:sleep(500), %% allow time for 'EXIT' to arrive in the > mailbox before "ack_delivery" message > self() ! {ack_delivery, Channel, DeliveryTag}, > loop(State); > _ -> > amqp_channel:call(Channel, #'basic.ack'{delivery_tag=DeliveryTag}), > loop(State) > end; > > {ack_delivery, Channel, DeliveryTag} -> > timer:sleep(50), %% ack delay > amqp_channel:call(Channel, #'basic.ack'{delivery_tag=DeliveryTag}), > loop(State); > > ... > > In the above snippet DelayAck specifies whether the actual ack happens > immediately or as a result of sending another message through loop/1. > When DelayAck is false the 'EXIT' message is received as expected. When > DelayAck is true there is a sleep of 500ms in order to allow the 'EXIT' to > arrive in the mailbox before the {ack_delivery, Channel, DeliveryTag} > message. But in this case the 'EXIT' message isn't received. The process > instead fails with a "noproc" when invoking amqp_channel:call/2 in > {ack_delivery...}. This makes sense since the Channel is now invalid, but I > did expect 'EXIT' to be received first thereby avoiding this failure. > Increasing the sleep before sending the {ack_delivery...} message doesn't > make any difference (except to delay the "noproc" failure). The behavior > described in this paragraph is consistent across several test runs. > > What would explain why the 'EXIT' message isn't received (ahead of the > ack_delivery message, or even at all) in the DelayAck case? > > Thanks, > Rich > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From eajam@REDACTED Thu Feb 26 01:38:54 2015 From: eajam@REDACTED (Alex Alvarez) Date: Wed, 25 Feb 2015 19:38:54 -0500 Subject: [erlang-questions] How to calculate series expansion e^x In-Reply-To: <2E28711F-E72D-4E90-A708-CB2782B958FF@cs.otago.ac.nz> References: <2E28711F-E72D-4E90-A708-CB2782B958FF@cs.otago.ac.nz> Message-ID: Or just simply... -module(e_fun). -export ([start/2]). start (N, X) -> 1 + step (N - 1, 1, X, 1.0, 0). step (0, _, _, _, S) -> S; step (N, NN, X, Z, S) -> ZZ = Z * X/NN, step (N - 1, NN + 1, X, ZZ, S + ZZ). Here I'm just reusing the each previous term (ZZ) of the Taylor series to compute the next term and then add it up to the sum (S). Cheers, Alex On 02/24/2015 10:27 PM, Richard A. O'Keefe wrote: > On 25/02/2015, at 11:00 am, Harit Himanshu wrote: > >> I am trying to learn Functional Programming and Erlang by practicing problems available online. >> >> One question where I don't know about solving it is >> >> The series expansion of ex is given by: >> >> 1 + x + x2/2! + x3/3! + x4/4! + ....... >> >> Evaluate e^x for given values of x, by using the above expansion for the first 10 terms. >> >> >> The problem statement could be found here >> >> Can someone guide me how this could be achieved in Erlang? > The first 10 terms of exp(X) are > X X^2 X^3 X^9 > 1 + --- + --- + --- + ... + --- > 1 2 6 9! > This is a polynomial. We can evaluate it cheaply using > Horner's Rule. Any time you have a polynomial to > evaluate, you should think about using Horner's Rule. > > X / X / X / X \ \ \ > 1 + --- * | 1 + --- * | 1 + --- * ... | 1 + --- | ...| | > 1 \ 2 \ 3 \ 9 / / / > > We can see a building block here: 1 + (X/n)*Rest. > > So let's make a function for the building block: > > step(X, N, Rest) > when is_float(X), is_float(N), is_float(Rest) -> > 1.0 + (X/N)*Rest. > > There are 9 steps, which is small enough to do by hand: > (NINE steps to get TEN terms. I hope that's clear.) > > exp(X) > when is_float(X) -> > step(X, 1.0, step(X, 2.0, step(X, 3.0, > step(X, 4.0, step(X, 5.0, step(X, 6.0, > step(X, 7.0, step(X, 8.0, step(X, 9.0, 1.0))))))))). > > > I should point out that this is a lousy way to compute > exp(X) for abs(X) "large". Waving hands vaguely, you > want X^10/10! "small". The relative error for X = 1.0 > is -1.1e-7, for X = 2.0 is -4.6e-5, and for X = 4.0 is > a scary -0.0081. > > One technique that's used in cases like this is > RANGE REDUCTION. e^x = 2^(1.442695... * x). > To begin, scale x by log of e to the base 2, > and separate that into an integer part N and a fraction > part F. e^x is then 2^(N+F) = 2^N*2^F. Since F is > "small", we can use something like this polynomial. > And then we can use the equivalent of C's ldexp() to > handle the 2^N* part. Or we could if Erlang _had_ an > equivalent of ldexp(). > > You don't really need the is_float/1 tests; I put them in > so that the compiler could generate better native code. > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From viktor@REDACTED Thu Feb 26 02:29:09 2015 From: viktor@REDACTED (=?UTF-8?B?VmlrdG9yIFPDtmRlcnF2aXN0?=) Date: Thu, 26 Feb 2015 02:29:09 +0100 Subject: [erlang-questions] [ANN] "MySQL/OTP" - rewritten MySQL driver In-Reply-To: References: Message-ID: <54EE76E5.3010007@zuiderkwast.se> What sort of code? I don't understand your question. / Viktor On 2015-02-25 21.01, Max Lapshin wrote: > Very good! > > Is there any code that can be shared across mysql / postgres drivers? From zxq9@REDACTED Thu Feb 26 02:56:32 2015 From: zxq9@REDACTED (zxq9) Date: Thu, 26 Feb 2015 10:56:32 +0900 Subject: [erlang-questions] public_key & OpenSSL format weirdness Message-ID: <17593736.biWWI7zZJk@changa> I have encountered a strange issue with the public_key and crypto modules regarding RSA key formats generated by OpenSSL. If I generate a private key in PEM format, public_key:pem_entry_decode/1 will not return an #'RSAPrivateKey'{} record, but if I generate the private key in DER format public_key:der_decode('RSAPrivateKey', KeyFile) will return the correct #'RSAPrivateKey'{}. Conversely, if I generate the public key in DER format public_key:der_decode('RSAPublicKey', PubFile) will give me an asn1 error, but if I generate the public key in PEM format public_key:pem_entry_decode/1 returns the correct #'RSAPublicKey'{} record. If I go one step further and decode the public key from a PEM file, then use public_key:der_encode/2 and write the resulting binary to a file as DER, then I can use the Erlang-generated DER of the public key with no problem. The I'm using "OpenSSL 1.0.1f 6 Jan 2014" on Linux. The following is a screen dump illustrating the problem, then another dump of some code illustrating the workaround: %%%%%%%%%%%%%%%% ceverett@REDACTED:~/Code/erlang/keytest$ cat keygen-der #! /bin/bash prefix=${1:?"Cannot proceed without a file prefix."} keyfile="$prefix"".key.der" pubfile="$prefix"".pub.der" openssl genpkey \ -algorithm rsa \ -out $keyfile \ -outform DER \ -pkeyopt rsa_keygen_bits:8192 openssl rsa \ -inform DER \ -in $keyfile \ -outform DER \ -pubout \ -out $pubfile ceverett@REDACTED:~/Code/erlang/keytest$ cat keygen-pem #! /bin/bash prefix=${1:?"Cannot proceed without a file prefix."} keyfile="$prefix"".key.pem" pubfile="$prefix"".pub.pem" openssl genpkey \ -algorithm rsa \ -out $keyfile \ -outform PEM \ -pkeyopt rsa_keygen_bits:8192 openssl rsa \ -inform PEM \ -in $keyfile \ -outform PEM \ -pubout \ -out $pubfile ceverett@REDACTED:~/Code/erlang/keytest$ ./keygen-der rsa1 ..................................................................................................................................................................................................................................................................................................................... ++ ............................................................................................................................................................................................................................................................................. ++ writing RSA key ceverett@REDACTED:~/Code/erlang/keytest$ ./keygen-pem rsa2 .......................................................................................................................................................................................................................................................................................................................................................................................................................... ++ ........................................................++ writing RSA key ceverett@REDACTED:~/Code/erlang/keytest$ erl Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false] Eshell V6.3 (abort with ^G) 1> rr("/usr/lib/erlang/lib/public_key-0.22.1/include/public_key.hrl"). ['AAControls','ACClearAttrs','AccessDescription', 'Algorithm','AlgorithmIdentifier', 'AlgorithmIdentifierPKCS-10','AlgorithmIdentifierPKCS-8', 'AlgorithmIdentifierPKCS5v2-0','AlgorithmIdentifierPKSC-7', 'AlgorithmNull','AnotherName','AttCertValidityPeriod', 'Attribute','AttributeCertificate', 'AttributeCertificateInfo','AttributePKCS-10', 'AttributePKCS-7','AttributeTypeAndValue', 'Attributes_SETOF', 'Attributes_SETOF_valuesWithContext_SETOF', 'AuthorityKeyIdentifier','BasicConstraints', 'BuiltInDomainDefinedAttribute','BuiltInStandardAttributes', 'Certificate','CertificateList','CertificationRequest', 'CertificationRequestInfo', 'CertificationRequestInfo_attributes_SETOF'|...] 2> {ok, DerKeyBin} = file:read_file("rsa1.key.der"). {ok,<<48,130,18,41,2,1,0,2,130,4,1,0,189,228,172,204,135, 175,97,84,205,254,58,197,47,41,196,...>>} 3> DerKey = public_key:der_decode('RSAPrivateKey', DerKeyBin). #'RSAPrivateKey'{version = 'two-prime', modulus = 8090848..., publicExponent = 65537, privateExponent = 7670114..., prime1 = 9729823..., prime2 = 8315513..., exponent1 = 4754084..., exponent2 = 6031370..., coefficient = 4497486..., otherPrimeInfos = asn1_NOVALUE} 4> {ok, DerPubBin} = file:read_file("rsa1.pub.der"). {ok,<<48,130,4,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5, 0,3,130,4,15,0,48,130,4,...>>} 5> DerPub = public_key:der_decode('RSAPublicKey', DerPubBin). ** exception error: no match of right hand side value {error,{asn1,{wrong_tag, {{expected,2}, {got,16, {16, [{6,<<42,134,72,134,247,13,1,1,1>>},{5,<<>>}]}}}}}} in function public_key:der_decode/2 (public_key.erl, line 219) 6> {ok, PemKeyBin} = file:read_file("rsa2.key.pem"). {ok,<<"-----BEGIN PRIVATE KEY-----\nMIISQwIBADANBgkqhkiG9w0BAQEFAASCEi0wghIpAgEAAoIEAQCs758ufZpw6gVn\nlcb3GDri0nWovuJ"...>>} 7> [PemKeyData] = public_key:pem_decode(PemKeyBin). [{'PrivateKeyInfo',<<48,130,18,67,2,1,0,48,13,6,9,42,134, 72,134,247,13,1,1,1,5,0,4,130,18,45, ...>>, not_encrypted}] 8> PemKey = public_key:pem_entry_decode(PemKeyData). #'PrivateKeyInfo'{version = v1, privateKeyAlgorithm = #'PrivateKeyInfo_privateKeyAlgorithm'{ algorithm = {1,2,840,113549,1,1,1}, parameters = <<5,0>>}, privateKey = [48,130,18,41,2,1,0,2,130,4,1,0,172,239,159,46, 125,154,112,234,5,103,149,198,247|...], attributes = asn1_NOVALUE} 9> {ok, PemPubBin} = file:read_file("rsa2.pub.pem"). {ok,<<"-----BEGIN PUBLIC KEY-----\nMIIEIjANBgkqhkiG9w0BAQEFAAOCBA8AMIIECgKCBAEArO+fLn2acOoFZ5XG9xg6\n4tJ1qL7iUiVxLzWM"...>>} 10> [PemPubData] = public_key:pem_decode(PemPubBin). [#'SubjectPublicKeyInfo'{algorithm = <<48,130,4,34,48,13, 6,9,42,134,72,134, 247,13,1,1,1,5,0,3, 130,4,15,0,48,130, ...>>, subjectPublicKey = not_encrypted}] 11> PemPub = public_key:pem_entry_decode(PemPubData). #'RSAPublicKey'{modulus = 7368345..., publicExponent = 65537} %%%%%%%%%%%%%%%% The PEM -> DER workaround for the public key: %%%%%%%%%%%%%%%% ceverett@REDACTED:~/Code/erlang/keytest$ cat keygen-asym #! /bin/bash prefix=${1:?"Cannot proceed without a file prefix."} keyfile="$prefix"".key.der" pubfile="$prefix"".pub.pem" openssl genpkey \ -algorithm rsa \ -out $keyfile \ -outform DER \ -pkeyopt rsa_keygen_bits:8192 openssl rsa \ -inform DER \ -in $keyfile \ -outform PEM \ -pubout \ -out $pubfile ceverett@REDACTED:~/Code/erlang/keytest$ ./keygen-asym rsa3 ............++ .............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................. ++ writing RSA key ceverett@REDACTED:~/Code/erlang/keytest$ erl Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false] Eshell V6.3 (abort with ^G) 1> {ok, PubPemBin} = file:read_file("rsa3.pub.pem"). {ok,<<"-----BEGIN PUBLIC KEY-----\nMIIEIjANBgkqhkiG9w0BAQEFAAOCBA8AMIIECgKCBAEAyqeCmfJNxPynjp8RDUWU\nKaEyLIrwv1WLfkmy"...>>} 2> [PubPemData] = public_key:pem_decode(PubPemBin). [{'SubjectPublicKeyInfo',<<48,130,4,34,48,13,6,9,42,134, 72,134,247,13,1,1,1,5,0,3,130, 4,15,0,48,130,...>>, not_encrypted}] 3> Pub1 = public_key:pem_entry_decode(PubPemData). {'RSAPublicKey',8634564...,65537} 4> PubDer = public_key:der_encode('RSAPublicKey', Pub1). <<48,130,4,10,2,130,4,1,0,202,167,130,153,242,77,196,252, 167,142,159,17,13,69,148,41,161,50,44,138,...>> 5> file:write_file("rsa3.pub.der", PubDer). ok 6> {ok, PubDerBin} = file:read_file("rsa3.pub.der"). {ok,<<48,130,4,10,2,130,4,1,0,202,167,130,153,242,77,196, 252,167,142,159,17,13,69,148,41,161,50,...>>} 7> Pub2 = public_key:der_decode('RSAPublicKey', PubDerBin). {'RSAPublicKey',8634564...,65537} 8> Pub1 = Pub2. {'RSAPublicKey',8634564...,65537} 9> {ok, KeyDerBin} = file:read_file("rsa3.key.der"). {ok,<<48,130,18,40,2,1,0,2,130,4,1,0,202,167,130,153,242, 77,196,252,167,142,159,17,13,69,148,...>>} 10> Key = public_key:der_decode('RSAPrivateKey', KeyDerBin). {'RSAPrivateKey','two-prime', 8634564..., 65537, 5179789..., 9406113..., 9179736..., 8502631..., 7664604..., 4453412..., asn1_NOVALUE} 11> TestMessage = <<"A test message.">>. <<"A test message.">> 12> Sig = public_key:sign(TestMessage, sha512, Key). <<129,61,138,16,14,168,75,66,38,125,157,33,233,114,150, 135,45,97,237,181,2,255,162,180,242,124,36,223,208,...>> 13> public_key:verify(TestMessage, sha512, Sig, Pub2). true 14> public_key:verify(TestMessage, sha512, Sig, Pub1). true %%%%%%%%%%%%%%%% What is going on here? From zxq9@REDACTED Thu Feb 26 03:01:22 2015 From: zxq9@REDACTED (zxq9) Date: Thu, 26 Feb 2015 11:01:22 +0900 Subject: [erlang-questions] public_key & OpenSSL format weirdness In-Reply-To: <17593736.biWWI7zZJk@changa> References: <17593736.biWWI7zZJk@changa> Message-ID: <34756234.SABLyJfnh7@changa> On 2015?2?26? ??? 10:56:32 zxq9 wrote: > I have encountered a strange issue with the public_key and crypto modules > regarding RSA key formats generated by OpenSSL. > > If I generate a private key in PEM format, public_key:pem_entry_decode/1 > will not return an #'RSAPrivateKey'{} record, but if I generate the private > key in DER format public_key:der_decode('RSAPrivateKey', KeyFile) will > return the correct #'RSAPrivateKey'{}. > > Conversely, if I generate the public key in DER format > public_key:der_decode('RSAPublicKey', PubFile) will give me an asn1 error, > but if I generate the public key in PEM format > public_key:pem_entry_decode/1 returns the correct #'RSAPublicKey'{} record. > > If I go one step further and decode the public key from a PEM file, then use > public_key:der_encode/2 and write the resulting binary to a file as DER, > then I can use the Erlang-generated DER of the public key with no problem. > > The I'm using "OpenSSL 1.0.1f 6 Jan 2014" on Linux. Comparing the OpenSSL generated DER and the Erlang generated DER, I found this: %%%%%%%%%%%%%% ceverett@REDACTED:~/Code/erlang/keytest$ cp rsa3.pub.der rsa3.pub.der.erlang ceverett@REDACTED:~/Code/erlang/keytest$ openssl rsa -inform DER -in rsa3.key.der -outform DER -pubout -out rsa3.pub.der.openssl writing RSA key ceverett@REDACTED:~/Code/erlang/keytest$ ls -l rsa3.pub.der.{erlang,openssl} -rw-rw-r-- 1 ceverett ceverett 1038 2? 26 10:58 rsa3.pub.der.erlang -rw-rw-r-- 1 ceverett ceverett 1062 2? 26 10:58 rsa3.pub.der.openssl ceverett@REDACTED:~/Code/erlang/keytest$ cmp -b rsa3.pub.der.erlang rsa3.pub.der.openssl rsa3.pub.der.erlang rsa3.pub.der.openssl ?????: ??? 4?? 1 12 ^J 42 " ceverett@REDACTED:~/Code/erlang/keytest$ cmp -b --ignore-initial=0:24 rsa3.pub.der.erlang rsa3.pub.der.openssl ceverett@REDACTED:~/Code/erlang/keytest$ erl Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false] Running $HOME/.erlang. Eshell V6.3 (abort with ^G) 1> {ok, OpenSSLBin} = file:read_file("rsa3.pub.der.openssl"). {ok,<<48,130,4,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5, 0,3,130,4,15,0,48,130,4,...>>} 2> {ok, ErlangBin} = file:read_file("rsa3.pub.der.erlang"). {ok,<<48,130,4,10,2,130,4,1,0,202,167,130,153,242,77,196, 252,167,142,159,17,13,69,148,41,161,50,...>>} 3> <<_:24/binary, ChoppedBin/binary>> = OpenSSLBin. <<48,130,4,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3, 130,4,15,0,48,130,4,10,2,...>> 4> ChoppedBin = ErlangBin. <<48,130,4,10,2,130,4,1,0,202,167,130,153,242,77,196,252, 167,142,159,17,13,69,148,41,161,50,44,138,...>> 5> %%%%%%%%%%%%%% So it appears there are 24 extra bytes appended to the OpenSSL generated DER that are confusing the asn1 import function, but only in the case of public RSA keys, as private OpenSSL generated DER keys match what is expected. From zxq9@REDACTED Thu Feb 26 04:18:48 2015 From: zxq9@REDACTED (zxq9) Date: Thu, 26 Feb 2015 12:18:48 +0900 Subject: [erlang-questions] public_key & OpenSSL format weirdness In-Reply-To: <34756234.SABLyJfnh7@changa> References: <17593736.biWWI7zZJk@changa> <34756234.SABLyJfnh7@changa> Message-ID: <79164446.cFXSGeCx77@changa> On 2015?2?26? ??? 11:01:22 zxq9 wrote: > So it appears there are 24 extra bytes appended to the OpenSSL generated DER > that are confusing the asn1 import function, but only in the case of public > RSA keys, as private OpenSSL generated DER keys match what is expected. Apparently OpenSSL adds an asn1 header, either on its own or because PKCS#1 demands it (or PKCS#8? I haven't found a clear reference, but it should be one of those), and Erlang, iOS and a few other environments that expect a public RSA key in DER format do not expect this header. The header is always <<48,130,4,34,48,13,6,9,42,134,72,134,247,13,1,1,1,5,0,3,130,4,15,0>> So I wonder if it wouldn't be better to either add a clause to public_key:der_decode/2 to catch this situation: der_decode(Asn1Type, <<48,130,4,34,48,13,6,9,42,134,72, 134,247,13,1,1,1,5,0,3,130,4,15,0, Der>>) -> der_decode(Asn1Type, Der); or (more properly) change the ASN.1 definition that generates OTP-PUB-KEY.erl in a way that makes 'dec_RSAPublicKey' derive from a CHOICE instead of a SEQUENCE type (or something along those lines -- I'm not sure where the asn1 module definition is... ?). In any case, this issue appears to be a persistent annoyance for folks using various RSA utilities: (http://blog.flirble.org/2011/01/05/rsa-public-key-openssl-ios/ http://blog.wingsofhermes.org/?p=42 http://blog.wingsofhermes.org/?p=75) -Craig From zxq9@REDACTED Thu Feb 26 04:46:38 2015 From: zxq9@REDACTED (zxq9) Date: Thu, 26 Feb 2015 12:46:38 +0900 Subject: [erlang-questions] public_key & OpenSSL format weirdness In-Reply-To: <79164446.cFXSGeCx77@changa> References: <17593736.biWWI7zZJk@changa> <34756234.SABLyJfnh7@changa> <79164446.cFXSGeCx77@changa> Message-ID: <1787801.ozU3b58TbT@changa> On 2015?2?26? ??? 12:18:48 zxq9 wrote: > On 2015?2?26? ??? 11:01:22 zxq9 wrote: > > So it appears there are 24 extra bytes appended to the OpenSSL generated > > DER that are confusing the asn1 import function, but only in the case of > > public RSA keys, as private OpenSSL generated DER keys match what is > > expected. > Apparently OpenSSL adds an asn1 header, either on its own or because PKCS#1 > demands it (or PKCS#8? I haven't found a clear reference, but it should be > one of those), and Erlang, iOS and a few other environments that expect a > public RSA key in DER format do not expect this header. Ah ha! So... perhaps the big problem is really a lack of documentation. It also seems that the canonical PKCS#1 asn1 definition is a bit ambiguous. In any case, there is an openssl tool that has the same effect as chopping off the first 24 bytes if invoked that way: $ openssl asn1parse -strparse 24 -inform DER -in rsa3.pub.der.openssl -out rsa3.pub.der.asn1parse 0:d=0 hl=4 l=1034 cons: SEQUENCE 4:d=1 hl=4 l=1025 prim: INTEGER :CAA7829... 1033:d=1 hl=2 l= 3 prim: INTEGER :010001 $ cmp -b rsa3.pub.der.asn1parse rsa3.pub.der.erlang $ # No differences now! This stupid little issue was really bothersome to get to the bottom of (and whatever the problem with using PEM formatted private keys is, it is probably related, since PEM is a base64 encoded DER binary inside). If our tools are going to be built on OpenSSL I think they should at least detect and comply with whatever (silly, maybe even wrong) output it produces instead of failing on the most likely form it is likely to encounter. The asn1 defintion in lib/public_key-0.22.1/asn1/PKCS-1.asn1 should be changed to allow a CHOICE type among the current canonical RSAPublicKey and an 'OpenSSL-RSAPublicKey' option, OpenSSL upstream should be "fixed" (if its even wrong, which technically it probably isn't) and document this to make it less of a pointless speedbump, or we might want to add an optional clause to public_key.erl to make sure we can accept the actual output of OpenSSL (since adding an OID header to RSA public keys appears to be what its always done). -Craig From lostcolony@REDACTED Thu Feb 26 05:32:41 2015 From: lostcolony@REDACTED (Christopher Phillips) Date: Wed, 25 Feb 2015 23:32:41 -0500 Subject: [erlang-questions] Supervising a Process that is Dependent on Another Process Message-ID: There are a couple of ways to achieve this, though not directly the way you describe. You would not pass in the Pid into the supervision spec, because the Pid can change any time a process restarts. Instead, you need to register the Pid to a name, and use the name. As a quick aside, it sounds like the second process is dependent on the first process being up. With that in mind, you'll likely want a rest_for_one supervision strategy, with the first process being the first in the child spec list. To your question, most gen_server examples actually are set up to do this for you, and you don't generally need the Pid, but if you're not using a gen_server you can manually use erlang:register/2, and erlang:whereis/1 to register the Pid to an atom, and to look up the Pid, as appropriate. That is, I can do something like the following for my first process (ellipsis are indicative of 'assume the proper arguments; not relevant to the answer at hand') - start_link() -> gen_server:start_link({local, NameToRegisterItAs}, ...). or if not using a gen_server, start_link() -> Pid = spawn_link(...), true = register(NameToRegisterItAs, Pid), Pid. and then elsewhere (my second process) where I need that Pid, I can use whereis(NameToRegisterItAs) to get the Pid. As long as you set up your supervisor correctly, and assuming a single node (else you may need to globally register it rather than locally) the registered Pid should always be the one the process is running under. > ------------------------------ > > Message: 7 > Date: Wed, 25 Feb 2015 14:03:44 -0500 > From: nx > To: erlang-questions > Subject: [erlang-questions] Supervising a Process that is Dependent on > Another Process > Message-ID: > VZMyw@REDACTED> > Content-Type: text/plain; charset=UTF-8 > > Is it possible to supervise a process that requires the Pid of another > process in its start_link function? > > I'm not clear on how I can get the supervisor to 1) start a process 2) > start another process with the Pid of the first process, then 3) > restart both of these if the first process fails and automatically > pass in the Pid of the restarted first process to the second process. > > I may be expecting too much from the supervisor. Any suggestions? > > Thanks! > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From lostcolony@REDACTED Thu Feb 26 06:31:12 2015 From: lostcolony@REDACTED (Christopher Phillips) Date: Thu, 26 Feb 2015 00:31:12 -0500 Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws badarg. How to monitor a remote process? Message-ID: For the first question (responding to both 'cause it's easier), I think it actually just doesn't work across nodes; if I supply node() as the param, spawn_opt/5 works just fine with monitor. Though yes, spawn_opt/3 is probably the same issue, in that it delegates to spawn_opt/5. I bet both are related to the fact that spawn_monitor doesn't accept a node option; the distribution protocol probably does not handle spawning and monitoring across nodes in an atomic fashion. For the second, could you trap exit signals and spawn_link, and then handle the exit messages? If an exit is from any other pid, or from the spawned one for a reason other than normal you can disable trapping exits and then exit for the received reason, but if it's from the spawned pid and normal you know it completed successfully, and you can then disable trapping exits, do a quick receive {'EXIT', ...} after 0 -> ok end in case of any new exit messages between handling the normal exit and disabling trapping, and then have the process go about its business. > > ---------------------------------------------------------------------- > > Message: 1 > Date: Mon, 23 Feb 2015 15:17:41 +0000 > From: Roger Lipscombe > To: "erlang-questions@REDACTED" > Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws > badarg. Documentation bug? > Message-ID: > < > CAJgnQd8UOZzY0kPyix0oRUygw8cC-KB8ZuhJfGyq7zX-U6u_ZQ@REDACTED> > Content-Type: text/plain; charset=UTF-8 > > I'm attempting to use spawn_opt/3 with a remote node, like this: > > Fun = fun() -> ok end, > {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). > > It fails with: > > {badarg, > [{erlang,spawn_opt, > ['imp_server@REDACTED',erlang,apply, > [#Fun,[]], > [link,monitor]], > []} > > Now, the documentation at > http://www.erlang.org/doc/man/erlang.html#spawn_opt-5 says that the > 'monitor' option is not allowed for spawn_opt/5. It says nothing about > spawn_opt/3. > > Looking at the error message, it looks like spawn_opt/3 simply calls > spawn_opt/5. Does this note about 'monitor' being unsupported need to > be in documentation for both functions? > > > ------------------------------ > > Message: 2 > Date: Mon, 23 Feb 2015 15:21:12 +0000 > From: Roger Lipscombe > To: "erlang-questions@REDACTED" > Subject: [erlang-questions] Using 'monitor' with spawn_opt/3 throws > badarg. How to monitor a remote process? > Message-ID: > < > CAJgnQd8t-RASC6RiJUTtfcFojp0KZVrWev4hpf7CAeOnD4pbow@REDACTED> > Content-Type: text/plain; charset=UTF-8 > > Note that, despite the preamble, this is a different question to the > other one I just posted. Honest. > > I'm attempting to use spawn_opt/3 with a remote node, like this: > > Fun = fun() -> ok end, > {Pid, Ref} = spawn_opt(Node, Fun, [link, monitor]). > > It fails with badarg. > > How do I monitor a process that I spawn on a remote node? > > If I use spawn_link followed by monitor, there's a race where the > remote process could have exited already, and I get {'DOWN', Ref, > process, Pid, noproc}, which is disconcerting. > > I want to know when it's finished. Preferably without it needing to > explicitly send a message back to me. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From s.j.thompson@REDACTED Thu Feb 26 08:12:59 2015 From: s.j.thompson@REDACTED (Simon Thompson) Date: Thu, 26 Feb 2015 07:12:59 +0000 Subject: [erlang-questions] SBLP 2015: 19th Brazilian Symposium on Programming Languages References: <201502260253.t1Q2rqKS031432@easychair.org> Message-ID: <54C5AFE8-626D-4C9C-8DCB-4E197534E367@kent.ac.uk> +++++++++++++++++++++++++++++++++++++++++++++++++++ CALL FOR PAPERS - SBLP 2015 19th Brazilian Symposium on Programming Languages 21-26 September 2015 Belo Horizonte, Brazil http://cbsoft.org/sblp2015 +++++++++++++++++++++++++++++++++++++++++++++++++++ IMPORTANT DATES Abstract submission: 20 April, 2015 Paper submission: 27 April, 2015 Author notification: 18 June, 2015 Camera ready deadline: 2 July 2015 INTRODUCTION The Brazilian Symposium on Programming Languages is a well-established symposium which provides a venue for researchers and practitioners interested in the fundamental principles and innovations in the design and implementation of programming languages and systems. SBLP 2015 is part of 6th Brazilian Conference on Software: Theory and Practice, CBSoft 2015, that will be held in Belo Horizonte, Minas Gerais, Brazil, from September 21st to September 26th, 2015. Authors are invited to submit original research on any relevant topic which can be either in the form of regular or short papers. TOPICS Topics of interest include, but are not limited to: * Program generation and transformation, including domain-specific languages and model-driven development in the context of programming languages. * Programming paradigms and styles, including functional, object-oriented, aspect-oriented, scripting languages, real-time, service-oriented, multithreaded, parallel, and distributed programming. * Formal semantics and theoretical foundations, including denotational, operational, algebraic and categorical. * Program analysis and verification, including type systems, static analysis and abstract interpretation. * Programming language design and implementation, including new programming models, programming language environments, compilation and interpretation techniques. INVITED SPEAKERS * Doaitse Swierstra, Utrecht University * TBA SUBMISSION AND PUBLICATION All submissions will be peer-reviewed and judged on the basis of its originality, contribution to the field, technical and presentation quality, and relevance to the symposium. Contributions should be written in Portuguese or English. Papers should fall into one of two different categories: regular papers, which can be up to 15 pages long in LNCS format, or short papers, with up to 5 pages in LNCS format. Short papers can discuss new ideas which are at an early stage of development and which have not yet been thoroughly evaluated. We encourage the submission of short papers reporting partial results of on-going master dissertations or doctoral theses. Accepted papers written in English will be published in a volume of Lecture Notes in Computer Science (LNCS), by Springer. Both regular and short papers must be prepared using the LNCS format, available at http://www.springer.com/computer/lncs?SGWID=0-164-6-793341-0. Papers must be submitted electronically (in PDF format) via the Easychair System: http://www.easychair.org/conferences/?conf=sblp2015. As in previous editions, after the conference, authors of selected papers will be invited to submit an extended version of their work to be considered for publication in a journal special issue. Since 2009, selected papers of each SBPL edition are being published in a special issue of Science of Computer Programming, by Elsevier. PROGRAM CHAIRS Alberto Pardo, Universidad de la Rep?blica, Uruguay Doaitse Swierstra, Utrecht University, The Netherlands PROGRAM COMMITTEE Alberto Pardo, Universidad de la Rep?blica (co-chair) Alex Garcia, IME Alvaro Moreira, Federal University of Rio Grande do Sul Andre Rauber Du Bois, Federal University of Pelotas Carlos Camar?o, Federal University of Minas Gerais Christiano Braga, Fluminense Federal University Doaitse Swierstra, Utrecht University (co-chair) Fabio Mascarenhas, Federal University of Rio de Janeiro Fernando Pereira, Federal University of Minas Gerais Fernando Castor, Federal University of Pernambuco Francisco Carvalho-Junior, Federal University of Ceara Hans-Wolfgang Loidl, Heriot-Watt University Jo?o Saraiva, University of Minho Jo?o F. Ferreira, Teesside University Louis-Noel Pouchet, University of California, Los Angeles Lucilia Figueiredo, Federal University of Ouro Preto Luis Barbosa, University of Minho Manuel A. Martins, University of Aveiro Marcelo Maia, Federal University of Uberl?ndia Marcelo D'Amorim, Federal University of Pernambuco Mariza Bigonha, Federal University of Minas Gerais Martin Musicante, Federal University of Rio Grande do Norte Noemi Rodriguez, PUC-Rio Peter Mosses, Swansea University Rafael Lins, Federal University of Pernambuco Renato Cerqueira, PUC-Rio Roberto Bigonha, Federal University of Minas Gerais Roberto Ierusalimschy PUC-Rio Rodrigo Geraldo, Federal University of Ouro Preto Sandro Rigo, State University of Campinas S?rgio Medeiros, Federal University of Rio Grande do Norte Simon Thompson, University of Kent Varmo Vene, University of Tartu Zongyan Qiu Peking University 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 roberto.ostinelli@REDACTED Thu Feb 26 09:13:12 2015 From: roberto.ostinelli@REDACTED (Roberto Ostinelli) Date: Thu, 26 Feb 2015 09:13:12 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> <93FF5FD5-B802-4B7E-ACA2-CF717892A3B5@widetag.com> Message-ID: I'm using the regular hibernate. Even so, the issue here is not only ram consumption, rather the inconsistency - going up and down, spikes, etc - that are not seen on the same system running without SSL. Thanks, r. > On 25/feb/2015, at 20:28, Erik S?e S?rensen wrote: > > Are you using the 'hibernate_after' ssl option? It made quite a difference in our application. From bob@REDACTED Thu Feb 26 10:35:52 2015 From: bob@REDACTED (Robert Wilkinson) Date: Thu, 26 Feb 2015 10:35:52 +0100 Subject: [erlang-questions] public_key & OpenSSL format weirdness In-Reply-To: <1787801.ozU3b58TbT@changa> References: <17593736.biWWI7zZJk@changa> <34756234.SABLyJfnh7@changa> <79164446.cFXSGeCx77@changa> <1787801.ozU3b58TbT@changa> Message-ID: <20150226093552.GA8593@fourtheye.org> On Thu, Feb 26, 2015 at 12:46:38PM +0900, zxq9 wrote: > On 2015?2?26? ??? 12:18:48 zxq9 wrote: > > On 2015?2?26? ??? 11:01:22 zxq9 wrote: > > > So it appears there are 24 extra bytes appended to the OpenSSL generated > the first 24 bytes if invoked that way: Hello Craig Please can you clarify? I think that the 24 bytes are added at the beginning, yet your use of the word "appended" implies to me that the bytes are added at the end? If the bytes are at the beginning, then "prepended" would be more properly used than "appended". Thank you for taking the time to go through the subtleties and nuances of OpenSSL, and PEM, BER, DER, ASN.1 et al. I know it is tricky! Bob From bchesneau@REDACTED Thu Feb 26 11:20:22 2015 From: bchesneau@REDACTED (Benoit Chesneau) Date: Thu, 26 Feb 2015 11:20:22 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> <93FF5FD5-B802-4B7E-ACA2-CF717892A3B5@widetag.com> Message-ID: On Thu, Feb 26, 2015 at 9:13 AM, Roberto Ostinelli < roberto.ostinelli@REDACTED> wrote: > I'm using the regular hibernate. Even so, the issue here is not only ram > consumption, rather the inconsistency - going up and down, spikes, etc - > that are not seen on the same system running without SSL. > > Thanks, > r. > > Nice trick :). How much time do you pass to the setting? Or rather which method did you use to find it? We have a similar issue there too using plain HTTP vs HTTPs makes a real difference and we observe a lot of spikes and so on in the memory too. - benoit > > > > On 25/feb/2015, at 20:28, Erik S?e S?rensen wrote: > > > > Are you using the 'hibernate_after' ssl option? It made quite a > difference in our application. > _______________________________________________ > 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 Thu Feb 26 11:17:46 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Thu, 26 Feb 2015 11:17:46 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> <93FF5FD5-B802-4B7E-ACA2-CF717892A3B5@widetag.com> Message-ID: <54EEF2CA.80107@ninenines.eu> He makes a good point, you are using hibernate yes, but that doesn't hibernate SSL processes themselves. With hibernate_after the SSL processes would hibernate too. Not sure if that would solve anything though, and SSL can probably be made more stable without the need to hibernate, which has a cost on its own. On 02/26/2015 09:13 AM, Roberto Ostinelli wrote: > I'm using the regular hibernate. Even so, the issue here is not only ram consumption, rather the inconsistency - going up and down, spikes, etc - that are not seen on the same system running without SSL. > > Thanks, > r. > > > >> On 25/feb/2015, at 20:28, Erik S?e S?rensen wrote: >> >> Are you using the 'hibernate_after' ssl option? It made quite a difference in our application. > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -- Lo?c Hoguin http://ninenines.eu From roberto@REDACTED Thu Feb 26 12:54:58 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Thu, 26 Feb 2015 12:54:58 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: References: <20150127190943.GA90397@ferdair.local> <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> Message-ID: > > Another tool, which WhatsApp aimed on was stud: > > https://github.com/bumptech/stud > > though the 200k buffer space per connection sound awfully large for a > large installation with lots of connections going on. > And that's exactly why I haven't considered stud in the first place. I have 200k connections on a box, so that would be.. 38GB? -------------- next part -------------- An HTML attachment was scrubbed... URL: From roberto@REDACTED Thu Feb 26 12:56:55 2015 From: roberto@REDACTED (Roberto Ostinelli) Date: Thu, 26 Feb 2015 12:56:55 +0100 Subject: [erlang-questions] Garbage Collection, BEAM memory and Erlang memory In-Reply-To: <54EEF2CA.80107@ninenines.eu> References: <20150128161934.GB90397@ferdair.local> <360A6593-9F4C-4695-B012-9373A404567F@widetag.com> <93FF5FD5-B802-4B7E-ACA2-CF717892A3B5@widetag.com> <54EEF2CA.80107@ninenines.eu> Message-ID: Ah yes, indeed. The SSL processes I keep forgetting about. I'm tempted to do another run with this option in. On Thu, Feb 26, 2015 at 11:17 AM, Lo?c Hoguin wrote: > He makes a good point, you are using hibernate yes, but that doesn't > hibernate SSL processes themselves. With hibernate_after the SSL processes > would hibernate too. > > Not sure if that would solve anything though, and SSL can probably be made > more stable without the need to hibernate, which has a cost on its own. -------------- next part -------------- An HTML attachment was scrubbed... URL: From darach@REDACTED Fri Feb 27 13:37:56 2015 From: darach@REDACTED (Darach Ennis) Date: Fri, 27 Feb 2015 12:37:56 +0000 Subject: [erlang-questions] [ANN] HDR Histogram 0.2.3 High Dynamic Range Histogram library for Erlang/OTP Message-ID: Hi folk, A high dynamic range histogram is one that supports recording and analyzing sampled data points across a configurable range with configurable precision within that range. The precision is expressed as a number of significant figures in the recording. This HDR histogram implementation is designed for recording histograms of value measurements in latency sensitive environments. Although the native recording times can be as low as single digit nanoseconds there is added overhead in this wrapper/binding due to both the frontend overhead of converting from native C to the NIF interface, and the erlang overhead incurred calling into the NIFs. C'est la vie, I suppose. A distinct advantage of this histogram implementation is constant space and recording (time) overhead with an ability to recycle and reset instances whilst reclaiming already allocated space for reuse thereby reducing allocation cost and garbage collection overhead in the BEAM where repeated or continuous usage is likely. For example, a gen_server recording metrics continuously and resetting and logging histogram dumps on a periodic or other windowed basis. Since announced at 0.1.0: * Moved to the HDR Histogram organization and is now part of that project * Histograms can now be easily iterated by record, linearly, logarithmically and by percentile * Histograms can now be serialized to and deserialized from zlib compressed or raw binary * Automated continuous integration tests via travis covering R16B02 .. R17.3 * Gitter service. This is a chat room where you'll find expertise on HDR Histogram in various flavors (Java, C, C#, Erlang ...) from authors, contributors and users. * Thanks. Heinz Gies of Project FIFO for contributing a patch. Mark Allen of Basho for feedback that improved docs and will influence the next version 0.3. Where: https://github.com/HdrHistogram/hdr_histogram_erl Enjoy! -------------- next part -------------- An HTML attachment was scrubbed... URL: From jose.valim@REDACTED Fri Feb 27 15:17:07 2015 From: jose.valim@REDACTED (=?UTF-8?Q?Jos=C3=A9_Valim?=) Date: Fri, 27 Feb 2015 15:17:07 +0100 Subject: [erlang-questions] Improve errors for maps Message-ID: Since maps are still marked are experimental, I would love if we take the opportunity to improve the errors coming from map operations. For example, a bad update just fails with badarg, without giving further hints of what went wrong: 1> (foo)#{foo := 1}. ** exception error: bad argument: foo Or when the key does not exist: 1> (#{})#{foo := 1}. ** exception error: bad argument in function maps:update/3 Although the shell helps a bit with formatting it, it is hard to decipher in logs and we frequently have reports of the error message not being clear to developers. I would love if we could, at least for the syntax based operations, introduce two errors: 1. {badmap, Term} - raised when a map was expected but got something else (this would replace the first error and it is an improvement over the error records used to raise) 2. {badkey, Key, Map} - raised when we expected a Map to have Key but it does not. Useful for the := syntax and it could also be used if we ever add an access operation to maps If we segregate the errors as proposed, we will have plenty of opportunity to improve the reports in shell and in error loggers. Thoughts? *Jos? Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Lead Developer -------------- next part -------------- An HTML attachment was scrubbed... URL: From lostcolony@REDACTED Fri Feb 27 16:17:21 2015 From: lostcolony@REDACTED (Christopher Phillips) Date: Fri, 27 Feb 2015 10:17:21 -0500 Subject: [erlang-questions] Supervising a Process that is Dependent on Another Process In-Reply-To: References: Message-ID: Sort of; you don't need a monitor because they're linked (so any process deaths will cause a death of the wrapper process, the eredis_sub process, and the eredis_smart_sub process). Make those calls from within your own process (maintaining the pid(s) you need in the process state), and supervise ~that~. If either your process, or either of the two that are spawned in the example code snippet on that page, die, the link will cause the other two to also die, your wrapper process to restart, and those two to reinitialize. Make all your calls through your wrapper process. That is, something like - *my_sup.erl init(_) -> MyProcSpec = ..., {ok, { {one_for_one, 10, 10}, [MyProcSpec]} . *my_proc.erl (I'm assuming this is a gen_server) init(_) -> {ok, EredisSubClient} = eredis_sub:start_link(), {ok, SubClient} = eredis_smart_sub:start_link(EredisSubClient), {ok, [{eredis_sub, EredisSubClient}, {eredis_smart_sub, SubClient}]}. handle_cast(A, State) -> proplists:get_value(eredis_smart_sub, State) ! A, ... {noreply, State}. handle_call(A, _, State) -> proplists:get_value(eredis_smart_sub, State) ! A, ... {reply, ..., State}. etc. You can also register those pids in my_proc:init, and reference them externally using whereis(WellKnownName), as I mentioned before, but you'll likely want to unregister them as part of the terminate (and in either case, you need to ensure that this process is up first in your supervisor hierarchy, before anything that relies on it, likely using rest_for_one, as mentioned before, so you don't end up sending messages to a pid that corresponds to nothing). On Thu, Feb 26, 2015 at 6:29 PM, Chase James wrote: > To bring the discussion closer to my problem domain, I'm specifically > trying to bring the eredis_smart_sub app > (https://github.com/nacmartin/eredis_smart_sub) under supervision, but > it requires the Pid of eredis to be passed in to its start_link > function. > > Because of the way its designed, is it safe to say you can't put it > under supervision directly without a wrapper module that uses the > registered eredis Pid and creates like a monitor or something for the > eredis_smart_sub gen_server? > > Thanks for your time and advice! > > On Wed, Feb 25, 2015 at 11:32 PM, Christopher Phillips > wrote: > > There are a couple of ways to achieve this, though not directly the way > > you describe. You would not pass in the Pid into the supervision spec, > > because the Pid can change any time a process restarts. Instead, you > need to > > register the Pid to a name, and use the name. > > > > As a quick aside, it sounds like the second process is dependent on the > > first process being up. With that in mind, you'll likely want a > rest_for_one > > supervision strategy, with the first process being the first in the child > > spec list. > > > > To your question, most gen_server examples actually are set up to do > this > > for you, and you don't generally need the Pid, but if you're not using a > > gen_server you can manually use erlang:register/2, and erlang:whereis/1 > to > > register the Pid to an atom, and to look up the Pid, as appropriate. > > > > > > That is, I can do something like the following for my first process > > (ellipsis are indicative of 'assume the proper arguments; not relevant to > > the answer at hand') - > > > > start_link() -> > > gen_server:start_link({local, NameToRegisterItAs}, ...). > > > > or if not using a gen_server, > > > > start_link() -> > > Pid = spawn_link(...), > > true = register(NameToRegisterItAs, Pid), > > Pid. > > > > > > > > and then elsewhere (my second process) where I need that Pid, I can use > > > > whereis(NameToRegisterItAs) > > > > to get the Pid. As long as you set up your supervisor correctly, and > > assuming a single node (else you may need to globally register it rather > > than locally) the registered Pid should always be the one the process is > > running under. > > > > > > > >> > >> ------------------------------ > >> > >> Message: 7 > >> Date: Wed, 25 Feb 2015 14:03:44 -0500 > >> From: nx > >> To: erlang-questions > >> Subject: [erlang-questions] Supervising a Process that is Dependent on > >> Another Process > >> Message-ID: > >> > >> > >> Content-Type: text/plain; charset=UTF-8 > >> > >> > >> Is it possible to supervise a process that requires the Pid of another > >> process in its start_link function? > >> > >> I'm not clear on how I can get the supervisor to 1) start a process 2) > >> start another process with the Pid of the first process, then 3) > >> restart both of these if the first process fails and automatically > >> pass in the Pid of the restarted first process to the second process. > >> > >> I may be expecting too much from the supervisor. Any suggestions? > >> > >> Thanks! > >> > >> > > > > _______________________________________________ > > 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 Fri Feb 27 16:27:04 2015 From: essen@REDACTED (=?UTF-8?B?TG/Dr2MgSG9ndWlu?=) Date: Fri, 27 Feb 2015 16:27:04 +0100 Subject: [erlang-questions] Improve errors for maps In-Reply-To: References: Message-ID: <54F08CC8.90508@ninenines.eu> On 02/27/2015 03:17 PM, Jos? Valim wrote: > 1. {badmap, Term} - raised when a map was expected but got something > else (this would replace the first error and it is an improvement over > the error records used to raise) > > 2. {badkey, Key, Map} - raised when we expected a Map to have Key but it > does not. Useful for the := syntax and it could also be used if we ever > add an access operation to maps > > If we segregate the errors as proposed, we will have plenty of > opportunity to improve the reports in shell and in error loggers. > > Thoughts? Sounds good. -- Lo?c Hoguin http://ninenines.eu From darach@REDACTED Fri Feb 27 16:34:43 2015 From: darach@REDACTED (Darach Ennis) Date: Fri, 27 Feb 2015 15:34:43 +0000 Subject: [erlang-questions] Improve errors for maps In-Reply-To: <54F08CC8.90508@ninenines.eu> References: <54F08CC8.90508@ninenines.eu> Message-ID: +1 On Fri, Feb 27, 2015 at 3:27 PM, Lo?c Hoguin wrote: > On 02/27/2015 03:17 PM, Jos? Valim wrote: > >> 1. {badmap, Term} - raised when a map was expected but got something >> else (this would replace the first error and it is an improvement over >> the error records used to raise) >> >> 2. {badkey, Key, Map} - raised when we expected a Map to have Key but it >> does not. Useful for the := syntax and it could also be used if we ever >> add an access operation to maps >> >> If we segregate the errors as proposed, we will have plenty of >> opportunity to improve the reports in shell and in error loggers. >> >> Thoughts? >> > > Sounds good. > > -- > Lo?c Hoguin > http://ninenines.eu > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nx@REDACTED Fri Feb 27 17:18:39 2015 From: nx@REDACTED (nx) Date: Fri, 27 Feb 2015 11:18:39 -0500 Subject: [erlang-questions] Supervising a Process that is Dependent on Another Process In-Reply-To: References: Message-ID: Oh this is excellent! Thanks! So basically I just have a gen_server that holds the two pids. If one pid dies the wrapper dies and gets restarted by the supervisor. That is a lot simpler than I thought! On Fri, Feb 27, 2015 at 10:17 AM, Christopher Phillips wrote: > Sort of; you don't need a monitor because they're linked (so any process > deaths will cause a death of the wrapper process, the eredis_sub process, > and the eredis_smart_sub process). Make those calls from within your own > process (maintaining the pid(s) you need in the process state), and > supervise ~that~. If either your process, or either of the two that are > spawned in the example code snippet on that page, die, the link will cause > the other two to also die, your wrapper process to restart, and those two to > reinitialize. Make all your calls through your wrapper process. That is, > something like - > > *my_sup.erl > > init(_) -> > MyProcSpec = ..., > {ok, { {one_for_one, 10, 10}, [MyProcSpec]} . > > > > *my_proc.erl (I'm assuming this is a gen_server) > > init(_) -> > {ok, EredisSubClient} = eredis_sub:start_link(), > {ok, SubClient} = eredis_smart_sub:start_link(EredisSubClient), > {ok, [{eredis_sub, EredisSubClient}, {eredis_smart_sub, SubClient}]}. > > handle_cast(A, State) -> > proplists:get_value(eredis_smart_sub, State) ! A, > ... > {noreply, State}. > > handle_call(A, _, State) -> > proplists:get_value(eredis_smart_sub, State) ! A, > ... > {reply, ..., State}. > > > etc. > > You can also register those pids in my_proc:init, and reference them > externally using whereis(WellKnownName), as I mentioned before, but you'll > likely want to unregister them as part of the terminate (and in either > case, you need to ensure that this process is up first in your supervisor > hierarchy, before anything that relies on it, likely using rest_for_one, as > mentioned before, so you don't end up sending messages to a pid that > corresponds to nothing). > > > On Thu, Feb 26, 2015 at 6:29 PM, Chase James > wrote: >> >> To bring the discussion closer to my problem domain, I'm specifically >> trying to bring the eredis_smart_sub app >> (https://github.com/nacmartin/eredis_smart_sub) under supervision, but >> it requires the Pid of eredis to be passed in to its start_link >> function. >> >> Because of the way its designed, is it safe to say you can't put it >> under supervision directly without a wrapper module that uses the >> registered eredis Pid and creates like a monitor or something for the >> eredis_smart_sub gen_server? >> >> Thanks for your time and advice! >> >> On Wed, Feb 25, 2015 at 11:32 PM, Christopher Phillips >> wrote: >> > There are a couple of ways to achieve this, though not directly the >> > way >> > you describe. You would not pass in the Pid into the supervision spec, >> > because the Pid can change any time a process restarts. Instead, you >> > need to >> > register the Pid to a name, and use the name. >> > >> > As a quick aside, it sounds like the second process is dependent on >> > the >> > first process being up. With that in mind, you'll likely want a >> > rest_for_one >> > supervision strategy, with the first process being the first in the >> > child >> > spec list. >> > >> > To your question, most gen_server examples actually are set up to do >> > this >> > for you, and you don't generally need the Pid, but if you're not using a >> > gen_server you can manually use erlang:register/2, and erlang:whereis/1 >> > to >> > register the Pid to an atom, and to look up the Pid, as appropriate. >> > >> > >> > That is, I can do something like the following for my first process >> > (ellipsis are indicative of 'assume the proper arguments; not relevant >> > to >> > the answer at hand') - >> > >> > start_link() -> >> > gen_server:start_link({local, NameToRegisterItAs}, ...). >> > >> > or if not using a gen_server, >> > >> > start_link() -> >> > Pid = spawn_link(...), >> > true = register(NameToRegisterItAs, Pid), >> > Pid. >> > >> > >> > >> > and then elsewhere (my second process) where I need that Pid, I can use >> > >> > whereis(NameToRegisterItAs) >> > >> > to get the Pid. As long as you set up your supervisor correctly, and >> > assuming a single node (else you may need to globally register it rather >> > than locally) the registered Pid should always be the one the process is >> > running under. >> > >> > >> > >> >> >> >> ------------------------------ >> >> >> >> Message: 7 >> >> Date: Wed, 25 Feb 2015 14:03:44 -0500 >> >> From: nx >> >> To: erlang-questions >> >> Subject: [erlang-questions] Supervising a Process that is Dependent on >> >> Another Process >> >> Message-ID: >> >> >> >> >> >> Content-Type: text/plain; charset=UTF-8 >> >> >> >> >> >> Is it possible to supervise a process that requires the Pid of another >> >> process in its start_link function? >> >> >> >> I'm not clear on how I can get the supervisor to 1) start a process 2) >> >> start another process with the Pid of the first process, then 3) >> >> restart both of these if the first process fails and automatically >> >> pass in the Pid of the restarted first process to the second process. >> >> >> >> I may be expecting too much from the supervisor. Any suggestions? >> >> >> >> Thanks! >> >> >> >> >> > >> > _______________________________________________ >> > erlang-questions mailing list >> > erlang-questions@REDACTED >> > http://erlang.org/mailman/listinfo/erlang-questions >> > > > From wallentin.dahlberg@REDACTED Fri Feb 27 18:26:33 2015 From: wallentin.dahlberg@REDACTED (=?UTF-8?Q?Bj=C3=B6rn=2DEgil_Dahlberg?=) Date: Fri, 27 Feb 2015 18:26:33 +0100 Subject: [erlang-questions] Improve errors for maps In-Reply-To: References: Message-ID: 2015-02-27 15:17 GMT+01:00 Jos? Valim : > Since maps are still marked are experimental, I would love if we take the > opportunity to improve the errors coming from map operations. > > For example, a bad update just fails with badarg, without giving further > hints of what went wrong: > > 1> (foo)#{foo := 1}. > ** exception error: bad argument: foo > > Or when the key does not exist: > > 1> (#{})#{foo := 1}. > ** exception error: bad argument > in function maps:update/3 > > Although the shell helps a bit with formatting it, it is hard to decipher > in logs and we frequently have reports of the error message not being clear > to developers. > > I would love if we could, at least for the syntax based operations, > introduce two errors: > > 1. {badmap, Term} - raised when a map was expected but got something else > (this would replace the first error and it is an improvement over the error > records used to raise) > > 2. {badkey, Key, Map} - raised when we expected a Map to have Key but it > does not. Useful for the := syntax and it could also be used if we ever add > an access operation to maps > > If we segregate the errors as proposed, we will have plenty of opportunity > to improve the reports in shell and in error loggers. > > Thoughts? > My relocation is that we already decided on this format? Pretty much precisely as you described it. It could just be long term deja vu on my part though. Is it your way of saying, "do it already" ? =D But yeah, +1 // Bj?rn-Egil > > *Jos? Valim* > www.plataformatec.com.br > Skype: jv.ptec > Founder and Lead Developer > > _______________________________________________ > erlang-questions mailing list > erlang-questions@REDACTED > http://erlang.org/mailman/listinfo/erlang-questions > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jose.valim@REDACTED Fri Feb 27 18:48:46 2015 From: jose.valim@REDACTED (=?UTF-8?Q?Jos=C3=A9_Valim?=) Date: Fri, 27 Feb 2015 18:48:46 +0100 Subject: [erlang-questions] Improve errors for maps In-Reply-To: References: Message-ID: > My relocation is that we already decided on this format? Pretty much > precisely as you described it. It could just be long term deja vu on my > part though. > Yes, James later pointed out I sent a very similar e-mail about 1 year ago. :( Is it your way of saying, "do it already" ? =D > It was not my intention but it would be awesome to have it indeed! *Jos? Valim* www.plataformatec.com.br Skype: jv.ptec Founder and Lead Developer -------------- next part -------------- An HTML attachment was scrubbed... URL: From wallentin.dahlberg@REDACTED Fri Feb 27 18:56:41 2015 From: wallentin.dahlberg@REDACTED (=?UTF-8?Q?Bj=C3=B6rn=2DEgil_Dahlberg?=) Date: Fri, 27 Feb 2015 18:56:41 +0100 Subject: [erlang-questions] Improve errors for maps In-Reply-To: References: Message-ID: 2015-02-27 18:48 GMT+01:00 Jos? Valim : > > My relocation is that we already decided on this format? Pretty much >> precisely as you described it. It could just be long term deja vu on my >> part though. >> > Nice spelling of "recollection" there .. > > Yes, James later pointed out I sent a very similar e-mail about 1 year > ago. :( > Ah, my sanity and memory is still relatively intact. Good. =) > > Is it your way of saying, "do it already" ? =D >> > > It was not my intention but it would be awesome to have it indeed! > No worries. I need to be reminded some times. ^^ // Bj?rn-Egil -------------- next part -------------- An HTML attachment was scrubbed... URL: From n.oxyde@REDACTED Fri Feb 27 18:57:17 2015 From: n.oxyde@REDACTED (Anthony Ramine) Date: Fri, 27 Feb 2015 18:57:17 +0100 Subject: [erlang-questions] Improve errors for maps In-Reply-To: References: Message-ID: Le 27 f?vr. 2015 ? 18:48, Jos? Valim a ?crit : > > My relocation is that we already decided on this format? Pretty much precisely as you described it. It could just be long term deja vu on my part though. > > Yes, James later pointed out I sent a very similar e-mail about 1 year ago. :( > > Is it your way of saying, "do it already" ? =D > > It was not my intention but it would be awesome to have it indeed! Could we some day start a discussion on the state of error reasons in Erlang/OTP? Some things are very clueless like discrepancies between the shell and compiled code ([ X || X <- [1], _ = foo ]), non-obvious discrepancies between some filters (replace _ = foo by just foo in previous example) or even plain useless error reasons like {badrecord,foo}. Could that be gradually improved on a large timescale? From petergi@REDACTED Sat Feb 28 04:04:57 2015 From: petergi@REDACTED (Peter J Etheridge) Date: Sat, 28 Feb 2015 14:04:57 +1100 Subject: [erlang-questions] EHTML resources? Message-ID: <7dd1695a0b12143c11b16c9f517225f2406a9c01@webmail.iinet.net.au> dear fellow list members, along with learning erlang i am also studying YAWS.in his manual Claes gives a snippet of code with some inserted EHTML. i thought i should study this as well, but my research so far has failed to uncover much information.is anyone aware of an authoritative source on EHTML?thank you to all those who provide answers. i read and usually learn from your responses.happy coding,peter -------------- next part -------------- An HTML attachment was scrubbed... URL: From eriksoe@REDACTED Sat Feb 28 08:42:48 2015 From: eriksoe@REDACTED (=?UTF-8?Q?Erik_S=C3=B8e_S=C3=B8rensen?=) Date: Sat, 28 Feb 2015 08:42:48 +0100 Subject: [erlang-questions] Supervising a Process that is Dependent on Another Process In-Reply-To: References: Message-ID: Just ensure that it wont terminate with 'normal' - or at least, that you in that case clean up explicitly. Den 27/02/2015 17.18 skrev "nx" : > Oh this is excellent! Thanks! So basically I just have a gen_server > that holds the two pids. If one pid dies the wrapper dies and gets > restarted by the supervisor. That is a lot simpler than I thought! > > On Fri, Feb 27, 2015 at 10:17 AM, Christopher Phillips > wrote: > > Sort of; you don't need a monitor because they're linked (so any process > > deaths will cause a death of the wrapper process, the eredis_sub process, > > and the eredis_smart_sub process). Make those calls from within your own > > process (maintaining the pid(s) you need in the process state), and > > supervise ~that~. If either your process, or either of the two that are > > spawned in the example code snippet on that page, die, the link will > cause > > the other two to also die, your wrapper process to restart, and those > two to > > reinitialize. Make all your calls through your wrapper process. That is, > > something like - > > > > *my_sup.erl > > > > init(_) -> > > MyProcSpec = ..., > > {ok, { {one_for_one, 10, 10}, [MyProcSpec]} . > > > > > > > > *my_proc.erl (I'm assuming this is a gen_server) > > > > init(_) -> > > {ok, EredisSubClient} = eredis_sub:start_link(), > > {ok, SubClient} = eredis_smart_sub:start_link(EredisSubClient), > > {ok, [{eredis_sub, EredisSubClient}, {eredis_smart_sub, SubClient}]}. > > > > handle_cast(A, State) -> > > proplists:get_value(eredis_smart_sub, State) ! A, > > ... > > {noreply, State}. > > > > handle_call(A, _, State) -> > > proplists:get_value(eredis_smart_sub, State) ! A, > > ... > > {reply, ..., State}. > > > > > > etc. > > > > You can also register those pids in my_proc:init, and reference them > > externally using whereis(WellKnownName), as I mentioned before, but > you'll > > likely want to unregister them as part of the terminate (and in either > > case, you need to ensure that this process is up first in your supervisor > > hierarchy, before anything that relies on it, likely using rest_for_one, > as > > mentioned before, so you don't end up sending messages to a pid that > > corresponds to nothing). > > > > > > On Thu, Feb 26, 2015 at 6:29 PM, Chase James > > wrote: > >> > >> To bring the discussion closer to my problem domain, I'm specifically > >> trying to bring the eredis_smart_sub app > >> (https://github.com/nacmartin/eredis_smart_sub) under supervision, but > >> it requires the Pid of eredis to be passed in to its start_link > >> function. > >> > >> Because of the way its designed, is it safe to say you can't put it > >> under supervision directly without a wrapper module that uses the > >> registered eredis Pid and creates like a monitor or something for the > >> eredis_smart_sub gen_server? > >> > >> Thanks for your time and advice! > >> > >> On Wed, Feb 25, 2015 at 11:32 PM, Christopher Phillips > >> wrote: > >> > There are a couple of ways to achieve this, though not directly the > >> > way > >> > you describe. You would not pass in the Pid into the supervision spec, > >> > because the Pid can change any time a process restarts. Instead, you > >> > need to > >> > register the Pid to a name, and use the name. > >> > > >> > As a quick aside, it sounds like the second process is dependent on > >> > the > >> > first process being up. With that in mind, you'll likely want a > >> > rest_for_one > >> > supervision strategy, with the first process being the first in the > >> > child > >> > spec list. > >> > > >> > To your question, most gen_server examples actually are set up to do > >> > this > >> > for you, and you don't generally need the Pid, but if you're not > using a > >> > gen_server you can manually use erlang:register/2, and > erlang:whereis/1 > >> > to > >> > register the Pid to an atom, and to look up the Pid, as appropriate. > >> > > >> > > >> > That is, I can do something like the following for my first process > >> > (ellipsis are indicative of 'assume the proper arguments; not relevant > >> > to > >> > the answer at hand') - > >> > > >> > start_link() -> > >> > gen_server:start_link({local, NameToRegisterItAs}, ...). > >> > > >> > or if not using a gen_server, > >> > > >> > start_link() -> > >> > Pid = spawn_link(...), > >> > true = register(NameToRegisterItAs, Pid), > >> > Pid. > >> > > >> > > >> > > >> > and then elsewhere (my second process) where I need that Pid, I can > use > >> > > >> > whereis(NameToRegisterItAs) > >> > > >> > to get the Pid. As long as you set up your supervisor correctly, and > >> > assuming a single node (else you may need to globally register it > rather > >> > than locally) the registered Pid should always be the one the process > is > >> > running under. > >> > > >> > > >> > > >> >> > >> >> ------------------------------ > >> >> > >> >> Message: 7 > >> >> Date: Wed, 25 Feb 2015 14:03:44 -0500 > >> >> From: nx > >> >> To: erlang-questions > >> >> Subject: [erlang-questions] Supervising a Process that is Dependent > on > >> >> Another Process > >> >> Message-ID: > >> >> > >> >> > >> >> Content-Type: text/plain; charset=UTF-8 > >> >> > >> >> > >> >> Is it possible to supervise a process that requires the Pid of > another > >> >> process in its start_link function? > >> >> > >> >> I'm not clear on how I can get the supervisor to 1) start a process > 2) > >> >> start another process with the Pid of the first process, then 3) > >> >> restart both of these if the first process fails and automatically > >> >> pass in the Pid of the restarted first process to the second process. > >> >> > >> >> I may be expecting too much from the supervisor. Any suggestions? > >> >> > >> >> Thanks! > >> >> > >> >> > >> > > >> > _______________________________________________ > >> > 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 eajam@REDACTED Sat Feb 28 09:48:26 2015 From: eajam@REDACTED (Alex Alvarez) Date: Sat, 28 Feb 2015 03:48:26 -0500 Subject: [erlang-questions] EHTML resources? In-Reply-To: <7dd1695a0b12143c11b16c9f517225f2406a9c01@webmail.iinet.net.au> References: <7dd1695a0b12143c11b16c9f517225f2406a9c01@webmail.iinet.net.au> Message-ID: ehtml is pretty much straight-forward as it follows the same format for the different HTML tags (e.g, {'div', [{id, ""}, {style, "