The web in a box - a next generation web framework for the Perl programming language

IRC log for #mojo, 2016-04-02

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary

All times shown according to UTC.

Time Nick Message
00:00 bpmedley I agree.  So, we are concurrently serving requests via one Mojolicious::Lite app.
00:00 thowe_work I think we would have to start with hypnotoad to get more
00:00 thowe_work or something
00:01 bpmedley Right on; however, the point is that we can serve an order of magnitude more than with the fork worker model.
00:01 bpmedley Also, the another point is that we have a non-blocking server by default.
00:02 thowe_work this is non-blocking?
00:02 jontaylor joined #mojo
00:02 bpmedley I think so.
00:03 thowe_work I thought we were only making one request at a time, very quickly, in a blocking scenario
00:03 woz joined #mojo
00:03 bpmedley I totally understand your point of view.  However, if we run a trace I don't think there will be a fork.
00:04 thowe_work in series, not simultaneously
00:04 bpmedley http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#REAL-TIME-WEB  <-- Would you read that again?
00:04 bpmedley And, this: http://mojolicious.org/perldoc/Mojo/Server/Daemon#DESCRIPTION
00:05 thowe_work I wasn't expecting a fork..  I thought your for loop executed the same query one ofter the other.  Are you saying it executed them at the same time?
00:05 bpmedley Aha!  One sec.
00:05 bpmedley do curl http://127.0.0.1:3000    &   <-- That was the goal with &
00:06 bpmedley Try changing the & to a ;
00:06 bpmedley $ date > when.time && for i in $(seq 1 100); do curl http://127.0.0.1:3000 ; done && date >> when.time
00:07 thowe_work ah, you were not waiting for the request to finish, I see.
00:08 bpmedley Sorry for my misunderstanding.  Do the requests per second make more sense given the "&"?
00:08 bpmedley I would think that the daemon server was handling 4-6 (maybe more, just guessing) GET requests at the same time..
00:08 bpmedley Do you agree/disagree?
00:08 thowe_work give me a sec, I'm trying to decide what you are asking me...
00:10 thowe_work I don't understand how I would know how many requests it was handling at once.
00:10 bpmedley Just approximately..
00:10 thowe_work why would it be handling more than one?
00:10 bpmedley Because that's the goal of concurrent.
00:11 thowe_work It's one process, isn't it simply answering and being asked again very quickly?  I didn't think we were yet doing anything concurrent.
00:11 bpmedley While one socket is i/o bound the server processes the code ref in the controller.  <-- I think that's the contexts; however, I'm a little iffy on that point.
00:12 bpmedley Let me think
00:13 thowe_work Is there one socket per process?
00:13 bpmedley No, that's the beauty of it.  There is one socket per concurrent request (I believe).
00:14 thowe_work You're saying this was a non-blocking example?  I thought we were demonstrating blocking first so we had something to compare non-blocking to.
00:14 bpmedley Hrmm
00:14 bpmedley Ok, one sec.
00:14 thowe_work This whole time I'm thinking we should be doing something that is slower on the back end...
00:17 thowe_work I've read a few times that you don't simply get non-blocking for free...  that you need to use these IO loops and such.
00:17 thowe_work so I assumed that's what we were showing: that we block by default.
00:20 bpmedley thowe_work : Please pull
00:21 bpmedley Also, are you in Linux?
00:22 thowe_work yeah this is debian at work
00:23 bpmedley Can you install apache/httpd?  I hope that includes ab.
00:23 bpmedley My for loop doesn't work.. :)
00:24 thowe_work insatlling apache2
00:24 thowe_work OK, I have ab now
00:25 bpmedley $ ab -n 1000 -r -l -c 50 http://127.0.0.1:3000/
00:25 bpmedley Also, if we could stop the daemon and restart with the usleep.
00:25 thowe_work already did
00:25 thowe_work this is going more slowly, obviously
00:26 thowe_work 400 requests completed
00:26 bpmedley If you would, comment out the usleep, restart, and run ab again..
00:26 thowe_work I like how it says to be patient...
00:27 thowe_work 101.5 seconds
00:27 bpmedley :)
00:27 sri oh my, today i'm not going to read all the backlog :S
00:27 bpmedley sri : Is the current conversation an issue?
00:28 thowe_work without usleep, 0.88 seconds
00:28 bpmedley thowe_work : Let me work on a non-blocking sleep example..
00:28 thowe_work I was thinking we should take to a different window.
00:29 bpmedley Ok, will do.
00:29 thowe_work bpmedley, OK, I have to go home.  I'll pick up with you there.
00:29 bpmedley I may not be around tonight.
00:29 sri bpmedley: maybe you should make a separate channel for your project
00:30 bpmedley sri : Ok, sorry about that.
00:30 thowe_work sri, sorry
00:30 bpmedley Mojolicious is so awesome we forget ourselves.. :-0
00:39 disputin joined #mojo
00:42 bpmedley https://gist.github.com/brianmed/4f6e26af5ec56fd0f6b469fb30373ed3 <-- Is this a good non-blocking timer example?
00:46 thowe joined #mojo
01:00 asarch joined #mojo
01:04 disputin joined #mojo
01:05 woz joined #mojo
01:20 marty joined #mojo
01:41 disputin joined #mojo
01:44 dvinciguerra joined #mojo
01:46 FatalNIX joined #mojo
01:54 VVelox bpmedley: Using FFmpeg and  Mojo::IOLoop::ReadWriteFork. Going to experiment with using the write stuff in the core later, but off hand  Mojo::IOLoop::ReadWriteFork seems more straight forward as I think I would have to end up reimplementing most of it anyways.
01:55 FatalNIX joined #mojo
01:56 VVelox bpmedley: Cool. Just looking at what you linked me to there.
02:43 noganex joined #mojo
02:54 disputin joined #mojo
03:00 ivi joined #mojo
03:07 woz joined #mojo
03:15 kaare joined #mojo
03:25 cpan_mojo Mojo-SlackRTM-0.02 by SKAJI https://metacpan.org/release/SKAJI/Mojo-SlackRTM-0.02
04:10 jberger bpmedley: i wouldn't access the stash as private data that way
04:11 bpmedley jberger : How would you rewrite that line?
04:11 disputin joined #mojo
04:14 jberger $c->stash->{data} = ...
04:14 jberger Or
04:14 jberger $c->stash(data => ... );
04:15 jberger But also, why are you removing a single occurrence timer?
04:15 jberger ... from its callback?
04:15 bpmedley $c->stash->{data} <-- I had forgotten we can do this
04:16 bpmedley Hrmm.  Should I use the finish event?
04:16 jberger ?
04:16 jberger You don't need to remove it, its already been fired
04:17 jberger I think you are thinking of recurring timers
04:17 bpmedley http://mojolicious.org/perldoc/Mojo/IOLoop#  <-- See the "Add a timer" example?
04:18 bpmedley Oh!  That's the Mojo::IOLoop->client $id, isn't it?
04:18 jberger Yeah
04:19 bpmedley Egads, my bad
04:19 jberger Haha np
04:22 bpmedley https://github.com/kraih/mojo/blob/master/lib/Mojo/Reactor/Poll.pm#L79  <-- Very important, eh?  :)
04:26 jberger bpmedley: I'm not sure what you mean
04:27 jberger timer instances are removed automatically once they fire, yes
04:27 bpmedley I simply didn't know that timer instances are removed via L79.
04:28 jberger Yeah
04:28 jberger All done for you
04:30 bpmedley jberger : Also, if you have time, how many contexts are there in a Mojo app?
04:33 jberger Contexts?
04:35 jberger bpmedley: i have no idea what you mean by that
04:36 bpmedley I've heard people mention that the particular section of code a callback is ran is referred to as a context.
04:37 jberger Do you mean a lexical scope?
04:37 jberger Oh no i think i know what you mean
04:37 bpmedley I don't think so.
04:38 jberger So when you setup the callback you are in a certain part of your code
04:38 jberger You start some nonblocking request
04:38 jberger But then you exit your function or whatever and the loop goes on
04:39 jberger Now when the code is executed it fires from the call frame of the loop itself
04:40 jberger Use Carp::cluck to write a stack trace before makinga nonblocking call and then do it again in the callback
04:40 jberger You are in a very different execution context
04:41 jberger I think that's probably what you've heard
04:41 bpmedley Sorry for the confusion, I'm not asking for the line numbers, or code sections.  I'm asking about nomenclature.  What are the contexts called?
04:41 bpmedley Also, your explanation is exactly what I'm talking about - just also would like nomenclature.
04:42 jberger You talk about your position in the stack frames (think caller())
04:43 jberger That collection of attack frames above you is the execution context
04:44 jberger Now that different from the lexical pad that the callback refers to
04:44 jberger Any lexicals that you close over ate still accessible from the callback
04:44 jberger *are
04:44 bpmedley Hrmm, I may be confused and that there really is no unique nomenclature, just code execution context.
04:45 jberger But think about the values of globals when you're callback is executed
04:45 bpmedley If not, we might should make up some jargon to see if things can be explained easier..
04:45 jberger This is why you can't use local with callbacks
04:45 jberger This is the terminology
04:46 jberger The state of the interpreter and the globals etc when the code is run
04:50 bpmedley What I'm suggesting is something like: the controller context; timer context; delay contex; etc.
04:57 jberger those aren't things
04:57 jberger what would those be?
04:57 jberger bpmedley: here's an example: http://paste.ubuntu.com/15585112/
04:58 jberger $x is a plain variable
04:58 jberger $y is a plain variable that we are going to make a local modification to
04:58 jberger $z is a lexical variable that we are going to lexically mask
04:59 bpmedley Just a sec.
04:59 jberger all three we will change the value within the scope that we initialize the callback
04:59 jberger then see what the value is when the code is actually executed
04:59 jberger can you guess what it will output
04:59 jberger ?
05:00 bpmedley I've never used local like that with IOLoop.
05:00 bpmedley So, I'm not 100% sure.
05:00 bpmedley Still want me to guess?
05:00 jberger sure
05:01 bpmedley x2     y1    z2
05:01 jberger yes
05:01 jberger well done
05:01 jberger now the important lesson is that when that callback is executed we can only trust that it's lexical data is what we expect
05:02 jberger local modifications will have unwound back to their original values
05:02 jberger and global variables (like $x in this case) might be changed before our code is executed
05:02 jberger I could add $x = 'x3'; before starting the loop
05:02 jberger or in a timer that fires in 0.5s
05:03 jberger so understanding the difference between your initialization context and your execution context is important
05:03 bpmedley I agree 100%.  My only curiosity is if a name should be given to the type of callback currently being executed.
05:04 jberger whatever name you would give it, I don't think I would call it "context"
05:05 bpmedley Hrmm.. one sec.
05:05 jberger what does it matter what type of nonblocking mechanism initialized the callback?
05:05 jberger to understand the callback arguments (usually called the signature, even though in perl it isn't really a signature in the usual sense)
05:05 jberger ?
05:06 bpmedley Only for knowledge transfer.  I wonder if that will make things easier to relate what is going on.
05:06 jberger if you are establishing the callback behavior a long ways away from where the callback is scheduled I suspect you are doing something overly confusing and I'd recommend refactoring
05:07 jberger you should be able to see the "context" by examining the nearby code
05:07 jberger Mojo::IOLoop->timer(1 => sub { #it is clear that this is the timer's callback });
05:08 woz joined #mojo
05:09 bpmedley Hrmm, let me think on an answer.
05:16 jberger there are certainly times when you are in a chain of delay steps that gets long and you start losing the thread of what's going on
05:17 jberger but that's when you start pulling chunks out and replacing those chunks with non-blocking methods
05:17 jberger https://www.youtube.com/watch?v=UGufeknRHjQ
05:18 jberger to bring it full circle, that talk is when I decided I needed to move to a real presentation framework rather than something I rolled at home :-P
05:19 bpmedley That makes sense.  And, I'm only advocating naming them when expressing these ideas either written or verbally.
05:20 jberger "the timer's callback" "the request's callback"
05:20 jberger works for me
05:22 jberger gah, rewatching this talk, it aged really badly
05:22 jberger Mango + Mandle example
05:23 jberger err, Mandel
05:23 jberger combine that with a presentation you can barely read :s
05:24 bpmedley I believe 2:26 sums it's up.. and, it's .... ..... ....
05:25 jberger later on I increase the size a lot
05:25 jberger which totally breaks the framing of the slide but at least you can read it
05:37 jberger I am glad we added the delay sugar that made these patterns cleaner
05:38 jberger Mojo::IOLoop->delay(sub { ... }, sub { ... }, ...)->catch(sub{ ... })->wait;
05:38 bpmedley Which is really sweet
05:41 jberger this talk predated namespaced helpers too
05:41 jberger man, a lot of this is really dated
05:41 jberger time for a redo on this talk :-P
05:43 jberger ok time for bed
05:43 * preaction smells a perl mongers volunteer
05:44 jberger the reason I gave that talk at mojoconf was that anywhere else I'd give that would be completely over everyone's head
05:44 jberger and mostly irrelevant
05:45 jberger only in a room full of Mojo users would that talk even stand a chance :-P
05:45 jberger nested non-blocking methods all using Mojo::IOLoop::Delay?!
06:09 dod joined #mojo
06:13 dod joined #mojo
06:16 woz joined #mojo
06:19 inokenty-w joined #mojo
07:40 woz joined #mojo
08:13 Vandal joined #mojo
08:26 sri bpmedley: where the callback gets finally executed is completely irreleavent
08:26 sri *irrelevant
08:27 sri what might be of interest though is that it will get triggered by a reactor event, and if we are already inside a reactor event, then by another one
09:12 woz joined #mojo
09:44 woz joined #mojo
10:26 HtbaaPi joined #mojo
10:34 bpmedley sri , jberger : Thanks for listening.. :)
10:59 woz joined #mojo
11:26 AndrewIsh joined #mojo
11:38 woz joined #mojo
11:52 disputin joined #mojo
12:33 woz joined #mojo
12:44 kes joined #mojo
12:56 jberger s1037989: you lost the dependencies https://github.com/jberger/Mojolicious-Plugin-SimpleSlides/commit/5086c0590b1e2684923190c01fbd585712a09133
12:57 s1037989 jberger: lost the dependencies?
12:58 s1037989 Oh, when i removed the files to let app git ship handle it, it didn't know what the deps were and i need to define that. Thanks!!
13:15 disputin joined #mojo
13:19 woz joined #mojo
13:22 woz_ joined #mojo
13:24 woz joined #mojo
13:49 vicash left #mojo
13:57 woz joined #mojo
13:58 vicash joined #mojo
14:02 jontaylor joined #mojo
14:18 batman s1037989: you need to extract the deps from the original Makefile.PL and put them into a cpanfile
14:25 woz joined #mojo
14:25 s1037989 batman: Thanks!
14:35 woz joined #mojo
14:36 tchaves joined #mojo
14:41 anon joined #mojo
14:47 tchaves joined #mojo
14:54 disputin joined #mojo
14:58 woz joined #mojo
14:58 disputin joined #mojo
15:01 mishanti1 I'm seeing a pretty weird error here. Is there a reason why Mojo would not see a cookie / session as valid on request #2, even though it was mojo that created it during the initial request? Mojo 3.97 btw.
15:03 jberger I don't think you're likely to get much advice on a mojo version that old
15:12 tchaves1 joined #mojo
15:18 Kripton joined #mojo
15:21 tchaves joined #mojo
15:25 dod joined #mojo
15:39 tchaves1 joined #mojo
15:46 marcus or rather, a lot of advice to upgrade
15:49 Adura joined #mojo
15:55 asarch joined #mojo
16:08 tchaves joined #mojo
16:59 woz joined #mojo
17:15 tchaves1 joined #mojo
17:32 tchaves joined #mojo
17:39 cpan_mojo Mojolicious-Plugin-SimpleSlides-0.04 by SADAMS https://metacpan.org/release/SADAMS/Mojolicious-Plugin-SimpleSlides-0.04
17:40 jberger s1037989++
17:49 tchaves joined #mojo
17:55 dvinciguerra joined #mojo
18:02 tchaves joined #mojo
19:02 woz joined #mojo
19:04 marty joined #mojo
19:08 woz_ joined #mojo
19:15 mishanti1 jberger, marcus: yeah, upgrading would be very nice, but does not really make business-sense in this case.
19:16 mishanti1 As a side-note: I did figure it out. Another projects deployment to the same server had some varnish vcl that was not scoped down to only affecting that projects requests.
19:20 jberger ah
19:20 mishanti1 Cursing was heard.
19:22 jberger I'll bet
19:31 cpan_mojo Mojolicious-Plugin-AssetPack-1.00 by JHTHORSEN https://metacpan.org/release/JHTHORSEN/Mojolicious-Plugin-AssetPack-1.00
19:36 jontaylor joined #mojo
19:37 PryMar56 joined #mojo
20:17 disputin joined #mojo
21:02 Mattes joined #mojo
21:02 Mattes hello
21:02 Mattes what is the best way to run a mojo-spider every 5 minutes?
21:03 preaction cron?
21:03 Mattes yes cron is possoble - but is a other way available?
21:04 Adura at?
21:04 preaction could you explain what kind of way you want?
21:05 Mattes i use mojo (with www:mechanize) to look for new content on diferent website. i will run the procedure every 5 minutes
21:05 preaction so, cron
21:05 preaction also, that's a terrible idea
21:05 Mattes ok - thank you very much!
21:05 Mattes terrible idea?
21:05 Mattes why?
21:06 jberger Mattes: most websites prohibit that kind of action, especially the ones you're likely looking at
21:06 jberger those ones have apis
21:07 Mattes APIs are not available (Unfortunately)
21:09 Mattes when using 3 or 5 different ips, one can make so (I hope)
21:10 preaction so you're deliberately working around detection to scrape the website. that's nice of you.
21:10 tencendur joined #mojo
21:10 Mattes do you have another suggestion?
21:10 umask001 what does this thing scrape?
21:10 preaction yes, don't
21:13 Mattes i will make a News-site (special topic) and for this i must spider different topic-websites in relatively short distances (so that one is present)
21:15 umask001 ok, I was thinking if it was an internal application then it might have a database or some other API access.  If it's a third party site then I'm afraid you don't have much choice.  It doesn't sound like a good idea to scrape it, and it's hard to maintain something like that since they might move the content
21:16 preaction okay, that's even worse. you're literally copying content without a license
21:21 disputin joined #mojo
21:23 Mattes No - I sont copy any content - to create a short text and then link directly to the original
21:23 Mattes 150 caracters
21:29 lluad joined #mojo
21:44 disputin joined #mojo
22:02 woz joined #mojo
22:54 disputin joined #mojo
22:58 kaare joined #mojo
23:06 tchaves joined #mojo
23:19 disputin joined #mojo

| Channels | #mojo index | Today | | Search | Google Search | Plain-Text | summary