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

IRC log for #mojo, 2016-02-10

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

All times shown according to UTC.

Time Nick Message
00:18 disputin joined #mojo
00:29 HtbaaPi joined #mojo
02:54 genio jberger: couldn't hurt to try
02:55 genio I was thinking of talking to a few of the others in the community to try to find a "best" way to approach tchrist about it.  It might come off better with a well laid out plan like you're talking about
02:55 mspo do you use $job->finish or return 1 in in an add_task ?
03:05 jberger genio: I have floated the idea to someone I believe might actually be able to execute a plan in that manner
03:05 jberger let's see if he/they act on it
03:06 jberger mspo: you can explicitly call finish but doing so is mostly done if you want to set the finish data (results)
03:06 genio nice!
03:06 genio jberger++
03:09 jacoby joined #mojo
03:09 jberger also I got a note back from the company that has perl.io parked
03:09 genio I think cpan.org would take quite a bit more effort as that's semi-ok
03:10 jberger they asked what I plan to do with it and gave a detailed response and even an offer to put a logo to their company on the resulting site
03:10 sri don't call $job->finish unless you have to
03:10 genio jberger: That sounds promising
03:10 sri it opens a new database connection and would just waste resources
03:12 noganex joined #mojo
03:17 jberger genio: here's another offender
03:17 jberger perl.org shows news from a site called http://perlnews.org/
03:17 jberger that seems to be well out of date too
03:17 jberger sigh
03:18 jberger this is why we can't have nice things
03:18 genio why are there so many sites?!?
03:18 jberger davorg owns that!! he should know better
03:19 sri because there's always someone going "i have a cool idea, lets make a new site to promote perl", without a plan for more than a few months
03:19 genio perl.org cpan.org blogs.perl.org perl.com perlnews.org search.cpan.org metacpan.org etc. etc.
03:20 sri if you don't have a plan for at least 5 years, i'd say just don't bother
03:21 jberger I'd rather see a twitter feed or the ironman feed there
03:21 genio cpantesters cpanratings
03:21 jberger or perlfoundation news
03:21 genio rt.cpan.org
03:22 jberger genio: lots of sites is good if they are maintained
03:25 genio meh.  I don't know how I feel about it.  It makes it feel too disjointed and confusing
03:45 mspo genio: it's too easy for technical people to keep websites up
03:46 mspo I haven't posted to my blog in four years now
03:46 mspo since I rewrote it (for the Nth time) as a way to check out mojolicious ;)
03:47 jberger that's part of my thought for perl.io if I get it
03:47 jberger I have a goal of entirely automated content
03:47 mcsnolte joined #mojo
03:48 mspo so many have that goal but maybe for different reasons ;)
03:49 jberger the email I sent back to the park.io guys: http://paste.scsys.co.uk/505209?tx=on&submit=Format+it%21
03:51 mspo "this guy wrote a really long email, up the price"
03:51 mspo anyway 'night
03:52 sri perl.ninja is also still available, for only 1300 euro per year
03:53 jberger I did wonder about that (the length) but I tried to show clearly that I didn't intend to make money and that I was representing an open source project
03:53 jberger and appealed on that level
03:53 jberger it will either work or it won't
03:57 mattp_ jberger: what are you trying to set up?
03:58 jberger like I say in the email, I want to make a site aimed outside the perl bubble showing clearly that perl is very active
03:58 jberger pull data from other resources, cache it and display it elsewhere
03:59 jberger s/elsewhere/on my site/
03:59 jberger make it pretty and modern looking
03:59 mattp_ jberger: is it?
04:00 jberger is what?
04:01 mattp_ is perl very active
04:01 jberger ....
04:01 jberger yearly releases, monthly development releases
04:01 jberger bunches of cpan uploads daily
04:02 jberger same for perl6 and that will only increase
04:02 jberger people seem to think that perl core development ended with 5.8 and since then has been basically maintenance mode
04:02 jberger I want to dispell that idea
04:06 jberger and if you don't know that, then clearly more information should be available :-P
04:07 sri honestly, i'd just redirect perl.org to metacpan.org :)
04:09 jberger that's not entirely true, there's more to perl than cpan
04:10 sri lol, that's dedication https://metacpan.org/recent?p=2
04:10 jberger wow
04:11 Grinnz yeah, thats why gumbypan has been silenced in f#perl for a while
04:11 Grinnz or was
04:14 genio wow
04:20 genio and I just realized we're forgetting all of the peripheral sites like YAPC and perlmongers and youtube videos of conference talks, etc.
04:22 jberger again, all of that is good generally, as long as it appears active
04:40 * sri wonders which parts of mojolicious are the performance bottlenecks now
04:41 sri in Mojo::DOM it's actually quite funny
04:42 sri the first is exactly what you'd expect, the tokenization regex https://github.com/kraih/mojo/blob/master/lib/Mojo/DOM/HTML.pm#L102
04:42 sri but the second is Scalar::Util::weaken https://github.com/kraih/mojo/blob/master/lib/Mojo/DOM/HTML.pm#L263
04:48 sri for a hello world lite app it's still Mojo::Headers
04:48 sri pretty much all over the place, so i guess any small optimizations there would be very noticeable
05:47 inokenty-w joined #mojo
05:47 sri *crickets*
06:01 sri btw. templates got significantly faster in 6.45
06:02 sri perl -Ilib -Mojo -E 'my $c = app->build_controller; n { $c->render(inline => "<%= 23 %>" x 100) } 10000'
06:02 sri simple one-liner like that went from 2.25s down to 1.64s
06:34 jegade joined #mojo
06:54 ashimema I love the fanaticism you guys give the code behind mojo. I learn so much from reading the irc logs and looking at the code. Just wanted to express my thanks to you all yet again :)
07:03 dod joined #mojo
07:09 dod joined #mojo
07:13 rabbit can anyone tell me why this is failing to clear the cookie? $self->cookie("ltt" => "", {expires => 1})
07:14 rabbit note that this *does* set it: $self->cookie("ltt" => "kakde843lkh3edafawq121fasdk", {expires => 1455174594})
07:27 firnsy i agree with ashimema, this channel is a daily ritual for me
07:27 firnsy ... and as someone who loves to write perl5, though is not active in the perl ecosystem, i perceive #mojo as the pointy end of perl5 and all the awesome it can provide
07:31 sugar joined #mojo
07:52 berov joined #mojo
08:17 Vandal joined #mojo
08:19 AndrewIsh joined #mojo
08:29 trone joined #mojo
08:37 circ-user-3zMRR joined #mojo
08:41 ashimema :)
08:41 rabbit can anyone tell me why this is failing to clear the cookie? $self->cookie("ltt" => "", {expires => 1})
08:41 rabbit note that this *does* set it: $self->cookie("ltt" => "kakde843lkh3edafawq121fasdk", {expires => 1455174594})
08:42 ashimema sorry rabbit, cookie handling isn't within my expertise area.. I'm using Mojo::JWT instead
08:42 rabbit ok ashimema, thanks.
08:43 ashimema I'm sure someone will be around soonish to help though.. there's a fair few europeans in here so it's getting up time ;)
08:44 rabbit ok, thanks. actually, I'm just about to head to bed
08:44 rabbit but I'll be back "-)
08:46 osfabibisi joined #mojo
09:42 kivilahtio joined #mojo
09:56 melo joined #mojo
10:26 harleypig joined #mojo
10:27 berov left #mojo
10:43 espen joined #mojo
10:56 mcsnolte joined #mojo
11:03 kriztw joined #mojo
11:18 kaare joined #mojo
11:20 wingfold_ joined #mojo
11:26 phillipadsmith_ joined #mojo
11:42 tki joined #mojo
11:44 tki Need to write a webservice that will generate some json for client is mojolicious overkill?
11:44 tki sorry for my bad english
11:44 pink_mist no it's not overkill
11:45 tki oh yeah i forgot - the webservice needs to be nonblocking
11:46 pink_mist perfect, mojolicious is almost your only choice then
11:47 sugar joined #mojo
11:54 berov joined #mojo
11:59 tki are there any non-blocking mysql drivers out there?
12:05 nic Take a look at Mojo::Mysql
12:06 tki nic: thanks!
12:31 jontaylor joined #mojo
12:45 inokenty-w joined #mojo
12:52 batman tki: it's "Mojo::mysql", but i guess that doesn't matter since a search engine will give you a match anyway :)
12:53 tki batman: thanks Im on it :)
12:53 batman cool
12:54 batman tki: let me know if you have any feedback regarding doc/usage
12:56 kivilahtio batman: hi there!
12:56 kivilahtio batman: we are using your new JSON::Validator
12:56 kivilahtio batman: our swagger spec was incredibly crappy, but thatnks to the validator we managed to clean it:)
12:57 kivilahtio batman: I even provided a pull request to Mojolicious. I am so proud of myself!
13:13 batman kivilahtio: glad to hear! please join #swagger if you have any further feedback/questions/whatever
13:14 kivilahtio batman: I tried to, but I couldn't find the IRC address
13:14 kivilahtio but now I did!
13:14 batman :)
13:48 neilhwatson joined #mojo
13:59 perlpilot joined #mojo
14:02 ramortegui joined #mojo
14:34 jacoby joined #mojo
14:36 vicash jberger: i am looking at the non-blocking use of Mojo part 2 for doing web crawling using Mojo::UserAgent. After render_later() is called, you invoke the $self->ua->get(...) which is blocking. So does Mojo automatically start serving other requests by invoking render_later ? But the blocking call is not completed though.
14:38 absolut_todd joined #mojo
14:40 Grinnz no, render_later only prevents automatic rendering at the end of the current dispatch
14:41 Grinnz you can't magically make blocking code not block
14:41 vicash Grinnz: if I have a blocking call after render_later which is slow, then does not performing automatic rendering really save anything ?
14:41 Grinnz no
14:42 vicash right. that clarifies it.
14:42 Grinnz disabling automatic rendering is so when you have a non-blocking call, it does not render a response while it's waiting in the event loop
14:43 Grinnz https://metacpan.org/pod/Mojolicious::Guides::Cookbook#Backend-web-services these sections describe non-blocking UA calls during request dispatch
14:43 vicash can I make calls to Postgresql using Mojo::Pg non-blocking without using transactions ?
14:43 Grinnz any Mojo::Pg query can be called non-blocking, as with Mojo::UserAgent
14:44 vicash Grinnz: thanks for the cookbook pointer. that is useful.
14:44 Grinnz ->delay helper is highly recommended for doing anything non-blocking during requests
14:45 Grinnz it automatically handles exceptions in the event loop callbacks as well
14:45 vicash yes i am looking at that example in mojo::pg now. had ignored it so far.
14:45 vicash thanks.
14:46 Grinnz note the delay helper and Mojo::IOLoop->delay arent quite the same thing. the delay helper does call Mojo::IOLoop->delay but it also does those extra things
14:46 Grinnz https://metacpan.org/pod/Mojolicious::Plugin::DefaultHelpers#delay
14:47 * vicash looks at the correct ->delay helper
14:50 vicash Grinnz: that's just what i needed. I appreciate the help.
14:58 kes joined #mojo
14:59 mcsnolte joined #mojo
15:03 dod joined #mojo
15:05 jacoby joined #mojo
15:13 coolo joined #mojo
15:18 sri ashimema, firnsy: :D
15:18 cpan_mojo Statocles-0.068 by PREACTION https://metacpan.org/release/PREACTION/Statocles-0.068
15:22 good_news_everyon joined #mojo
15:22 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vga9x
15:22 good_news_everyon mojo/master fa8311b Sebastian Riedel: show a single non-blocking request too
15:22 good_news_everyon left #mojo
15:31 sri so, we have two pull requests already today
15:33 vicash i want to dynamically create a plot with some data using javascript. However, my current method is to place this JS code between <script> tags in the template. is there a way that I can generate a temporary .js file and then have that be picked up by the template ? Can I use the default helper reply->asset for this ?
15:33 sri hmm, the first one is security relevant https://github.com/kraih/mojo/pull/905
15:33 sri it doesn't seem to actually solve a problem though
15:36 Grinnz_ vicash: you can create a Mojo::Asset::Memory then serve that with reply->asset
15:36 dod joined #mojo
15:36 Grinnz_ vicash: you can also just put it in a string and serve it as text
15:37 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Custom-responses
15:38 vicash thanks.
15:41 sri not sure what to make of this one https://github.com/kraih/mojo/pull/904
15:42 batman sri: i don't think #904 need fixing
15:42 * sri nods
15:42 jberger firnsy: stick them with the pointy end
15:42 * jberger looks at issues
15:43 batman and i don't get how #905 is a security issue. won't it just make /not being able to post data/ a bit more confusing?
15:43 batman i also don't get why you want multiple csrf on one page :(
15:44 sri not a security issue, but security relevant
15:44 batman ok.
15:44 sri accepting multiple tokens sounds like an attack vector to me
15:44 sri i just don't see a good reason for allowing it
15:44 batman oh! i thought #905 was suggesting to use the last instead of the first csrf
15:45 batman i think it's a really bad idea to check /all/ csrf tokens
15:45 sri no, right now we only accept a single token or it matches against the ref value, which always fails
15:46 batman i think todays behaviour makes sense
15:48 sri i guess if he wants to test the current behavior i'd be ok with that
15:50 jberger I wouldn't add a croak on non leading slash personally
15:50 * sri nods
15:50 jberger the reason being IF we eventually wanted to use JSON References somehow
15:50 jberger https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03
15:50 sri so far we don't pretend to validate DSLs
15:50 jberger for which a JSON pointer is just the fragment
15:51 batman jberger: i'm using that all over the place in Swagger2/JSON::Validator
15:51 batman works like a charm
15:51 jberger I know
15:51 jberger that's where I learned about it
15:51 batman the "$ref" is "#/foo/bar". not "foo/bar"
15:52 jberger I'm saying if we wanted to integrate that more tightly into our json stuff more tightly at some point
15:52 batman but how is that an argument to die if you are missing a leading "/" ?
15:52 sri oh, also well spotted batman, that test case is broken
15:52 batman ...did i miss out on something?
15:52 batman sri: thanks :)
15:52 jberger no I'm saying I don't want to die on a missing /
15:53 jberger specifically because there are relevant near-by technologies which would require not dying in that case
15:54 jabberwok left #mojo
15:54 jabberwok joined #mojo
15:55 batman jberger: which tech allows a json pointer without leading "/" ...?
15:56 jberger it has a # before it
15:56 ubuntu_ joined #mojo
15:56 jberger I don't know what the interface would look like
15:57 batman what is "it" ?
15:57 jberger the pointer-like reference
15:57 batman there's no json pointer that looks like "#/foo".
15:57 batman what you do is Mojo::URL->new("#/foo")->fragment <--- that's the json pointer ("/foo")
15:58 jberger ok so my point was that we might eventually want an api that resolves those
15:58 batman when i say "there isn't" i mean "i haven never seen anything like that"
15:59 jberger if you are advocating the opposite then perhaps it should die on non leading /
15:59 jberger I just had what I thought was a possible reason not to that wasn't just "because we don't do things like that"
15:59 ubuntu_ Hi! I want to write my own logger that is called for $self->app->logger->debug(). I assume I need to write my own logger plugin for this to work. Is this true? Can you please point me to documentation on how to do it?
15:59 batman jberger: i can still advocate the opposite and still think it's not useful to die on invalid input.
16:00 jberger ubuntu_: Mojo applications have a logger built in
16:00 Caldrin Nick 'ubuntu_' was accidently set. Sorry.
16:00 batman Caldrin: do you want to replace $app->log() ?
16:00 Grinnz_ why write your own? there are tons of loggers already and some of them even have the same interface as Mojo::Log
16:00 jberger Caldrin: http://mojolicious.org/perldoc/Mojo#log
16:00 Caldrin I want to control where to log and how.
16:00 jberger and like Grinnz_ says, there are others out there
16:00 batman Caldrin: $app->log->on(message => sub { log_to_database(@_) });
16:00 Grinnz_ https://metacpan.org/pod/Mojo::Log#message
16:01 jberger http://shadow.cat/blog/matt-s-trout/mstpan-16/
16:01 Grinnz_ you can override the message event (and unsubscribe the default one) to do whatever you want
16:03 Caldrin What I do want is the following: My app already has lots of app->log() calls. They used to log using Log4perl which worked nice. In the future they need to log both to Log4perl and a self written database logger.
16:03 Caldrin I'd rather have a way to keep the $app->log calls.
16:03 batman Caldrin: Log4perl can also log to database
16:03 Grinnz_ i was gonna say, cant log4perl do this itself?
16:04 batman Caldrin: and you can even add your own logger function to Log4perl which does *whatever*
16:04 Grinnz_ its a bit overcomplicated for my taste, but for a reason
16:04 * batman used to think overcomplicated was a sign of quality :/
16:05 Grinnz_ sometimes its more a sign of trying to predict too many use cases :)
16:05 batman :)
16:06 dod joined #mojo
16:06 genio "But this one outlying case that could happen once in every 10 billion years _absolutely must_ be accounted for!!!"
16:06 Caldrin With Log4perl you need to configure a database log appender. That keeps risk of misconfiguration. Also, the database logger exists and should be reused.
16:06 wingfold joined #mojo
16:06 Grinnz_ sorry not sure i followed that...
16:09 preaction wrap your database logger in a Log::Log4perl::Appender
16:09 preaction or make yourself a Mojo::Log subclass that accepts multiple Mojo::Log objects and logs to all of them, but that's crazier
16:10 Caldrin "log4perl can log into database" - we considered that. The way to do it is to have a Log4perl::Appender. This appender needs to be in the config file. We are afraid that misconfiguration will prevent log4perl to call the logger. Getting log4perl config right is hard.
16:10 Caldrin We already had issues with Log4perl config.
16:11 preaction so write a monitor that ensures that the correct logs have been written in the last X minutes, X hours, X days, etc...
16:11 Caldrin Since all modules that are not using Mojo do use MooseX::Log::Log4perl we substituted MooseX::Log4perl with our own role that does the right thing.
16:12 preaction it doesn't largely matter, log4perl is a bunch of globals
16:17 Caldrin I'll look into what Mojo allows me with overwriting. Thanks for all your comments.
16:22 jacoby joined #mojo
16:27 vicash Grinnz: going back to reply->asset() with Mojo::Asset::Memory. Can I do this: <code>$c->reply->asset($my_js_code); $c->render;</code> and the template will get rendered fine ?
16:27 Grinnz_ if it's a template, you don't need an asset...
16:28 Grinnz_ https://metacpan.org/pod/Mojolicious::Guides::Rendering#Rendering-inline-templates
16:28 Grinnz_ if it's just text, see the section right below that
16:29 vicash it is none of these actually. i want to create a JS file with a huge amount of data for plotting and pass that in the template as <script src='tmp.js'/>, so I was planning on using reply->asset() for that and render the template accordingly
16:30 Grinnz_ is it on the filesystem?
16:30 Grinnz_ or are you creating it on the filesystem?
16:31 Grinnz_ you can use Mojo::Asset::File to refer to a file path, i believe that was in the earlier linked examples of serving assets
16:31 vicash i am generating it based on the request, so it is a new file per request
16:32 Grinnz_ you can also generate it directly in a Mojo::Asset::File which will create a temp file for you if not given a path
16:32 vicash yes i saw that but i must be doing something wrong. i will keep trying.
16:33 mullagain joined #mojo
16:33 mullagain i am having an issue serving static files
16:33 mullagain Mojo is saying that the file does not exist, when it clearly does
16:34 mullagain I have tried full path and relative to the parent directory with no luck
16:34 Grinnz_ it should be relative to your static paths, which defaults to public/ in the base directory
16:34 mullagain so it has to be in the public directory?
16:34 Grinnz_ you can set your own paths: https://metacpan.org/pod/Mojolicious::Static#paths
16:34 mullagain i only want these files to be served if the user is logeged in.
16:34 mullagain ok
16:34 mullagain thanks
16:35 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Tutorial#Static-files
16:35 Grinnz_ ah, if you want to put them behind a login you will have to make a dynamic route
16:35 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Serving-static-files
16:35 mullagain got that part down
16:35 mullagain so can I access the paths from the controller?
16:35 mullagain like app->paths?
16:35 Grinnz_ reply->static will use the same paths that i mentioned though
16:36 Grinnz_ app->static->paths
16:36 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Custom-responses
16:36 mullagain so i can push(@{app->static->paths},'some/path');
16:36 Grinnz_ it should be an abs dir
16:37 Grinnz_ (you can use app->home->rel_dir)
16:37 Grinnz_ https://metacpan.org/pod/Mojo::Home#rel_dir
16:40 mullagain ok, i added the path to static
16:40 mullagain still not working
16:41 Grinnz_ show code?
16:41 sri just don't add and remove them for every request
16:41 mullagain $VAR1 = [
16:41 mullagain '/home/jisnmm1/wd/sitedb/public',
16:41 mullagain '/home/jisnmm1/wd/sitedb/var/files'
16:41 mullagain ];
16:41 sri please don't ever paste into an irc channel
16:41 jberger mullagain / Grinnz_: if you are trying to hide static files behind a login, using static paths is the wrong solution
16:42 mullagain get '/file/:id' => sub {
16:42 mullagain my $c = shift;
16:42 mullagain my $id = $c->stash('id');
16:42 mullagain my $sth = $c->db->prepare('select sha,name from site_file where site_file_id = ?');
16:42 mullagain $sth->execute($id);
16:42 mullagain $c->render( status => 404, text => 'file not found' );
16:42 mullagain }
16:42 mullagain }
16:42 Grinnz_ ...
16:42 jberger mullagain: use a paste site
16:42 mullagain http://pastebin.com/2XaV9WHy
16:42 mullagain sorry
16:43 sri if chanserv wasn't borked for me, that would be a timeout from the channel
16:43 mullagain [Wed Feb 10 10:39:49 2016] [debug] Static file "/home/jisnmm1/wd/sitedb/var/files/1c16084d7cbc1bc054127bbe20e32f355950389652bf05d2c920d42de7c3dc22" not found
16:44 sri joined #mojo
16:45 mullagain so, i am using the custom response, but it is saying that the file does not exist.
16:45 mspo does the file exist?
16:45 mullagain absolutely
16:45 jberger make a Mojo::Asset::File
16:46 mspo that's probably better
16:46 jberger and then reply->asset http://mojolicious.org/perldoc/Mojolicious/Plugin/DefaultHelpers#reply-asset
16:47 mspo what's wrong with per-request static paths?
16:47 sri http://mojolicious.org/perldoc/Mojolicious/Guides/Rendering#Custom-responses
16:47 sri mspo: caching
16:48 sri and concurrent requests
16:48 mspo sri: oh yeah I think I ran into that when i was trying it
16:48 mullagain asset worked
16:48 mullagain thanks!
16:48 mspo sri: I was trying to add virtual hosting to my mojo app and ran into some problems with it
16:48 mspo hacked a bunch of stuff into before_dispatch and before_routes
16:49 sri you just don't change anything in $app during requests
16:49 mspo but I wanted per-vhost routes and static paths
16:49 jberger the logic there is "while I have a logged in user, this file is available to everyone"
16:50 jberger I don't think that's what you want
16:50 sri mspo: we already have that http://mojolicious.org/perldoc/Mojolicious/Guides/Routing#Mount-applications
16:51 mspo I think app-per-vhost was the only natural way to map things; and just abstract out the shared logic into plugins and stuff
16:51 mspo sri: well it was a little more nuanced because I also wanted global fallbacks
16:51 mspo I've given up on it for now
16:55 rabbit joined #mojo
16:56 rabbit I'm trying to figure out why I am able to set a cookie using: $self->cookie(ltt => 'kakde843lkh3edafawq121fasdk', {expires => 1455209627}) but I'm not able to clear it using: $self->cookie(ltt => '', {expires => 1})
16:56 rabbit It just ain't disappearing
16:57 mspo what do the headers look like on each request
16:58 rabbit I will have to get back to you on that ....
16:58 rabbit I will check
16:59 captbipto joined #mojo
17:00 sri MOJO_DAEMON_DEBUG=1
17:00 sri then you see everything that goes over the wire
17:02 zivester joined #mojo
17:03 PryMar56 joined #mojo
17:08 good_news_everyon joined #mojo
17:08 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgVZh
17:08 good_news_everyon mojo/master d14e796 Sebastian Riedel: make sure multiple CSRF tokens are rejected (closes #905)
17:08 good_news_everyon left #mojo
17:09 good_news_everyon joined #mojo
17:09 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgVnY
17:09 good_news_everyon mojo/master 7169ceb Sebastian Riedel: just use the same token twice
17:09 good_news_everyon left #mojo
17:23 wingfold joined #mojo
17:26 chienjo joined #mojo
17:37 Vitrifur joined #mojo
18:09 disputin joined #mojo
18:15 good_news_everyon joined #mojo
18:15 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgVr5
18:15 good_news_everyon mojo/master 352f98d Sebastian Riedel: WebSocket connections are always non-blocking
18:15 good_news_everyon left #mojo
18:50 genio They ever answer you back on perl.io?
18:52 patrickz joined #mojo
18:59 jberger not yet
19:10 dod joined #mojo
19:10 asarch joined #mojo
19:20 bjakubski joined #mojo
19:22 rabbit sri: mssp: my previous question was: I'm trying to figure out why I am able to set a cookie using: $self->cookie(ltt => 'kakde843lkh3edafawq121fasdk', {expires => 1455209627}) but I'm not able to clear it using: $self->cookie(ltt => '', {expires => 1})
19:22 rabbit mspo that is (not mssp)
19:23 rabbit here are the headers
19:23 rabbit There are pre and post headers. These are post request
19:23 rabbit http://mibpaste.com/qYV2Cl
19:25 rabbit hum.......
19:25 rabbit just noticed something
19:25 rabbit these headers are on a per url basis?
19:25 rabbit are the cookies stored on a per url basis? strange
19:25 Grinnz_ the cookies you set that way are for that response only
19:26 Grinnz_ but the client normally retains it
19:26 rabbit well, the thing is this
19:26 vicash is there a way to get Mojo::Date to return to_string() values in a specific timezone ?
19:26 Grinnz_ do you mean per domain? cause cookies are domain specific
19:26 rabbit for -- Server <<< Client (), I see the cookies listed in the header
19:26 rabbit but for this -- Server >>> Client (http://192.168.1.135:3000/acc) I do not see the cookies listed
19:27 rabbit no, I do not mean per domain, but per uri
19:27 Grinnz_ right, you haven't told it to send any cookies back
19:27 rabbit wowzee. I haven't?
19:27 Grinnz_ and it doesn't need to unless you want to change something
19:27 rabbit yes, I want to delete those cookies, but the request I'm deleting them on is a different uri, but same domain
19:28 Grinnz_ you're not passing a path, so the cookies should be applicable to the whole domain
19:28 Grinnz_ (if the client is sending them, then it applies)
19:28 rabbit ok I think I get that ...
19:28 rabbit so on the print headers output, first thing is domain specific, so it shows all my cookies
19:29 rabbit so why does $self->cookie(ltt => '', {expires => 1}) not delete the cookie?
19:30 Grinnz_ o'
19:30 Grinnz_ i'm not that familiar with the controller cookie method, i guess 'ltt' is the cookie name?
19:30 Grinnz_ seems so yes
19:30 rabbit yes, in this case
19:31 rabbit it has no problem setting the cookie
19:31 sri time to take a step back, that HTTP response you pasted does not have a Set-Cookie header, so you did somethign wrong
19:31 Grinnz_ hmm that should cause it to expire the cookie
19:31 rabbit why does it need a Set-Cookie header if I did not set a cookie? The cookies were set on a previous request
19:32 rabbit However, those are the correct cookies that were set
19:32 Grinnz_ "delete a cookie" is really "send a cookie with the same name and an expiration that's already passed"
19:32 sri ok, then i don't understand what you want
19:32 Grinnz_ the server can only return new headers on a new request, it can't change what the browser stores otherwise
19:32 rabbit yes, delete a cookie is set rval to blank and in a time in the past
19:32 punter joined #mojo
19:33 Grinnz_ right, in a new response cookie
19:34 rabbit I'm going to try something different. Maybe the problem is that there is no rvalue. I will set it to some random rvalue and see what happens.
19:36 Grinnz_ vicash: Mojo::Date doesnt do anything with timezones, I would suggest passing the epoch into a Time::Moment then use https://metacpan.org/pod/distribution/Time-Moment/lib/Time/Moment.pod#Converting-from-instant-time-to-designated-time-zone
19:36 Grinnz_ you could also just pass the epoch into a DateTime object but that's slower
19:36 vicash Grinnz_: yes I was trying to avoid using DateTime. will look at Time::Moment
19:37 Grinnz_ unfortunately you still need DateTime::TimeZone for the moment, unless just using a specific timezone offset is good enough for your case
19:37 vicash ah ok. i will explore both options then
19:38 Grinnz_ (timezones are hard :)
19:42 rabbit http://mibpaste.com/BfNRje : when logging on, cookies are set, but when logging off, no cookies are set.
19:42 Grinnz_ and what are you doing in the logoff action?
19:43 rabbit sorry, I pasted the wrong header for the logoff ...
19:44 rabbit http://mibpaste.com/kg1RxU : I should have pasted this
19:45 jberger https://www.pottermore.com/news/ww-publishing-cursed-child-script-book-announcement
19:45 jberger oops
19:45 jberger well that's good too
19:45 jberger http://memegenerator.net/instance/60354791
19:46 Grinnz_ huh, theres an official 8th book?
19:46 jberger oh yeah, just announced
19:47 Grinnz_ rabbit: well that looks correct to me
19:48 rabbit yes, but cookies on firefox remain set at the old values, as though my "set in the past" action did nothing at all.
19:48 mspo did anything else change like the domain in the url bar?
19:48 mspo http vs https
19:49 Grinnz_ you dont have any ajax running that's possibly re-setting the cookies? :)
19:49 rabbit it's a good question; I don't see any changes at all.
19:49 rabbit mspo: if you look at the (last) cut and paste, you will see that it's the same domain
19:50 rabbit namely, http://192.168.1.135:3000
19:50 Grinnz_ rabbit: that's from the server's point of view, whats important is what your browser thinks it is
19:50 rabbit right, ok, well, I am using some aliases in the code, but not here
19:51 rabbit on the test server, it's 100% http://192.168.1.135:3000
19:51 mspo you can also use curl -vvv -c cookies.txt http://192.168.1.135:3000
19:51 rabbit could apache vhosts be interfering at all, or is this 100% apart from apache? I'm using morbo
19:51 mspo and examine cookies.txt on each
19:52 mspo rabbit: a cookie without an explicit domain is set on whatever you're currently using
19:52 perlpilot left #mojo
19:53 perlpilot joined #mojo
19:53 rabbit l
19:55 rabbit mspo: curl -vvv -c cookies.txt http://192.168.1.135:3000 returns: http://mibpaste.com/4jIX4W
19:57 rabbit I will set explicit domain and path and see what happens ....
19:57 rabbit hang on ...
19:57 mspo rabbit: look at cookies.txt
19:57 mspo and then run the curl again
19:58 mspo and look at cookies.txt
19:58 rabbit I do not see cookies.text
19:58 rabbit did not create as far as I can see
19:58 mspo I don't see any set-cookies in your curl
19:58 rabbit ah, OK
19:58 mspo sorry maybe you need to use adj
19:58 rabbit well, i need to use a different url
19:59 rabbit one that include the logon params that sets the cookies
20:01 mspo it helps to hit the url with the issue when troubleshooting :)
20:09 rabbit Grinnz_, mspo: when I explicitly set the domain, it works.
20:09 rabbit So I'm going to consider this solved.
20:09 rabbit Thank you for your help.
20:10 mspo cool
20:10 rabbit I learned about printing and examining headers and that's very valuable.
20:10 rabbit Thanks a lot.
20:10 Grinnz_ also, what a mess cookies are :)
20:10 rabbit yeah, true
20:11 rabbit basically, to solve the mess, I'm setting domain to '.' . _simple_host($self->req->url->to_abs->host), where _simple_host strips 'www.'
20:23 rabbit mspo, Grinnz: while I'm working on expiring individuals cookies (and that now works), I cannot get the session to expire. I've tried the following.
20:23 rabbit http://mibpaste.com/VEwKLx
20:23 rabbit None of those is working.
20:23 rabbit Is it because the session is not being explicitly set?
20:26 rabbit Note, this is not critical since I only really need to delete individual cookies right, I can revisit this another day.
20:26 rabbit since I've already got the first part working :-)
20:28 jberger rabbit: I'm sure you've seen this but http://mojolicious.org/perldoc/Mojolicious/Controller#session
20:29 jberger that first one seems to be it
20:29 sri also, login is the whole topic of the growing guide
20:30 sri wonder if there's anything we can do to make this hotspot faster https://github.com/kraih/mojo/blob/master/lib/Mojo/Headers.pm#L62-L70
20:31 sri ->headers->content_type(...) and the like result in *a lot* of method calls
20:33 sri perhaps something like $headers->default(Date => ...) could replace the "$headers->date(...) unless $headers->date" pattern
20:34 sri there's a lot of those all over the place https://github.com/kraih/mojo/blob/master/lib/Mojo/WebSocket.pm#L88
20:39 mspo sri: how are you measuring this stuff?
20:39 mspo sri: flamegraph generators?
20:40 jberger NYTProf I'd assume
20:42 rabbit jberger, sri: Thanks. The issue must be I'm not using authentication provided by mojolicious, since I'm retrofiting some existing code; I'll incorporate that later.
20:42 Grinnz_ mojolicious doesnt really provide authentication
20:45 jberger rabbit: do you mean you aren't using mojo's session?
20:46 sri yea, nytprof
20:47 sri in this specific case i'm profiling with "perl -d:NYTProf -Ilib examples/hello.pl daemon -l http://*:8080 -m production"
20:47 sri and then run wrk against it a few times
20:49 mspo I don't see why those lines do a lot of work
20:49 mspo they seem so straightforward
20:49 sri they get called a lot
20:50 sri Mojo::Headers::header maybe 20 times per request
20:50 sri at 1000 rps that's 20000 calls per second
20:51 sri and each call results in a few more method calls
20:51 sri suddenly stuff starts to add up
20:51 sri newer versions of perl do help a lot actually, since method calls got much faster
20:52 sri but i still think we can do better with the Mojo::Headers api
20:52 mspo well you could manually unroll this: my %NORMALCASE = map { lc() => $_ } ( ..  :)
20:56 sri that only happens during startup
20:57 sri so any change there does nothing for performance
20:57 sri everything in the header method is the hotspot
21:00 sri let me upload some profiling data
21:02 sri have a look yourself http://mojolicious.org/nytprof/index.html
21:05 rabbit Grinnz_, jberger: yes, I was referring to authentication, which was incorrect, since setting cookies should have nothing to do with authentication
21:05 rabbit but as for this, https://metacpan.org/pod/Mojolicious::Sessions, the answer is, yes, I'm *not* using it
21:05 rabbit which maybe I shoulid be
21:06 rabbit so when I set cookies, it is using the traditional method, as opposed to mojolicious
21:06 rabbit (or something like that)
21:06 sri would be nice to get this faster http://mojolicious.org/nytprof/lib-Mojo-Headers-pm-78-line.html#62
21:07 Grinnz_ rabbit: the ->session method on controller uses that
21:07 Grinnz_ it won't work with a cookie you set normally
21:07 mspo so the problem is that it was called 1.4M times?
21:08 sri maybe
21:09 mspo sri: it would seem like there should be a group of "always" or "almost always" headers that you could optimize into fewer calls
21:09 inokenty joined #mojo
21:09 batman sri: what about this? https://gist.github.com/jhthorsen/79008b6229c014ba6440
21:09 mspo but I'm not really reading it well enough, just BSing
21:09 sri batman: did you measure it?
21:10 batman sri: nope. but there's far less method calls.
21:10 sri i'm only interested in cold hard numbers! ;p
21:11 storskegg joined #mojo
21:15 batman good thing you are! https://gist.github.com/jhthorsen/79008b6229c014ba6440 :/
21:16 sri your patch is borked anyway
21:16 sri there is no name argument
21:17 sri you've stumbled upon something interesting though
21:17 sri those generated methods can be optimized more
21:17 sri the hash key can be generated in advance as well
21:19 orev is it ok to use getopt::long inside a mojo (lite) app, or will it conflict with the standard mojo command line usage?
21:19 sri the difference is substantial
21:20 sri batman: https://gist.github.com/anonymous/24ebc6cf3d349126c5b2
21:20 batman https://gist.github.com/jhthorsen/79008b6229c014ba6440 ?
21:20 sri if i test that one with examples/fast.pl results go from 1629 rps up to 1740 rps
21:21 jberger orev: not sure how you'd use it in the app itself
21:21 jberger it is usually used from in the command system
21:21 orev jberger: I'm writing a command line app that does some of the same things as my web mojo app, so I wanted to leverage some functions like config, etc... in the command line one
21:22 jberger orev: that's what the command system is for
21:22 batman sri: can i make a commit? :)
21:22 jberger orev: http://mojolicious.org/perldoc/Mojolicious/Guides/Cookbook#Adding-commands-to-Mojolicious
21:24 sri batman: your patch still has flaws
21:25 batman oh? "All tests successful."
21:25 orev jberger: wow, ok.  yet another amazing thing in mojo.  thanks
21:25 batman do you mean the double lc() stuff?
21:25 sri batman: ye
21:25 jberger orev: commands are really cool
21:25 jberger I use them a lot
21:25 rabbit Grinnz_: thanks. I'll use the session method later when I've got the rest of the code working
21:26 batman sri: cleaned that up after seing your patch :)
21:27 batman sri: how about doing the same in sub header() ?
21:27 sri batman: so, is the performance gain woth the 9 lines?
21:28 sri batman: i think we mostly use the shortcut methods
21:28 sri so changes in header() might be irrelevant for performance
21:29 batman sri: i agree on keeping header() as is
21:29 sri don't just agree, benchmark! :D
21:29 batman sri: i don't know how to use nytprof :/
21:30 sri you mean how to use it from the command line, or how to interpret the results?
21:30 sri first part i can teach you in a minute
21:31 batman the first. (don't know how to use it with mojo)
21:31 batman i've used nytprof with normal scripts
21:31 sri ah, it's super easy then
21:32 sri "perl -d:NYTProf -Ilib examples/hello.pl daemon -l http://*:8080 -m production"
21:32 batman sri: i retract my agreement. i forgot that header() is actually used quite a lot for each request.
21:32 sri then run wrk against that server "wrk -c 100 -d 10s http://127.0.0.1:8080"
21:32 orev jberger: so if I have the app running, and then need to use a command, will that interfere with the running app?
21:32 sri ctrl-c the server
21:32 jberger orev: no, its a new instance of the app
21:32 sri "nytprofhtml; open nytprof/index.html"
21:32 sri that's all
21:33 jberger orev: this is when you get to start realizing that the webserver (which has an instance of the app) is not the app itself
21:33 jberger and then you level up
21:33 batman sri: oh. i was hoping it was easier. thanks :)
21:33 sri Oo
21:34 pink_mist wow such difficult much complex
21:34 pink_mist no, kidding =)
21:35 sri batman: in this case i think wrk running against "perl -Ilib examples/fast.pl daemon -m production -l http://*:8080" should be evidence enough too
21:36 sri 120 rps difference is pretty obvious
21:36 sri i tend towards saying yes to the monkey_patch patch, and no to additional header() changes
21:37 sri if you grep mojolicious for "->header(" there's pretty much nothing
21:38 sri now i do wonder if we can turn some of the optimized code into shared functions without losing performance again :)
21:41 sri nope, i can measure the difference
21:41 melo joined #mojo
21:44 sri batman: yea, just commit the patch
21:47 sri batman: lol, one more thing
21:47 sri all the generated methods have a %NORMALCASE entry ;p
21:48 sri so that's useless
21:48 sri more performance!
21:48 batman sri: busy with https://gist.github.com/jhthorsen/9744e3dec887e89f50be :P
21:48 batman sri: will fix that as well -- %NORMALCASE
21:49 sri i'm golfing now
21:50 sri https://gist.github.com/anonymous/e984a8b25b0365dc0cfb
21:50 sri and i'm very +1 on this now
21:50 sri the old version had so much useless overhead
21:51 sri especially normalcase handling
21:51 sri that version results in 1750 rps for me now
21:52 sri that's a 130 rps win
21:54 orev jberger: are commands autoloaded by searching the filesystem?  currently I'm using separate packages in one file
21:54 batman oh! you don't need $self->{normalcase} because names() will always match *something* in %NORMALCASE ?
21:55 batman sri: nevermind. i see it now
21:55 jberger orev: I haven't tried that before
21:55 jberger single file multiple packages are ewwww anyway though (usually)
21:55 sri $self->{normalcase} actually has a funny history
21:55 sri i only noticed in 2012 that there was a nasty memory leak with %NORMALCASE
21:56 sri https://github.com/kraih/mojo/commit/48f2f7042472d9ba5fcbc791524ccda31235723b
21:57 batman sri: was the memory leak significant..?
21:57 sri now, where it gets funny is that the same leak existed in HTTP::Headers, so for a time i could run pretty much any perl web app out there out of memory with a few carefully crafted headers
21:57 batman seems like you need a lot of requests to actually leak much memory...?
21:57 sri nobody noticed the leak in all the time HTTP::Headers existed
21:57 sri not at all, you just need a bunch of unique headers
21:58 batman AH! right
21:58 * batman need to get some sleep...
21:58 sri i don't think HTTP::Headers has a header limit to this day
21:58 sri batman: don't forget to commit
21:58 batman sri: i guess that patch is now yours. go crazy :)
21:59 sri no, you started it, you commit my last gist :)
21:59 batman I WILL COMMIT. THEN GO TO BED!
21:59 batman :)
22:00 jberger sri: I don't see how your patch fixes the leak
22:00 sri jberger: new headers would be added to %NORMALCASE before
22:01 sri which is global
22:01 batman jberger: the first version stored $lcname into a "global" variable instead of the object tied to the current request
22:01 sri so, any new header you encounter in the wild makes %NORMALCASE grow
22:02 sri the patch makes new headers only go into $self->{normalcase}, which gets destroyed regularly
22:03 jberger oh, the instance isn't long-lived, I forgot that
22:03 jberger gotcha
22:03 sri and we have a 100 line limit
22:03 jberger and message size limits etc
22:03 sri so, no risk of "A: A\r\nB: B\r\nC: C\r\n"
22:04 sri you can put a lot of headers into 16mb ;p
22:04 sri message size limit won't protect you
22:04 sri you really need a line limit too
22:07 sri oh, it's happening again https://metacpan.org/recent
22:10 batman sri: https://gist.github.com/jhthorsen/98507bdfc50e5536838b <--- keys v.s. values?
22:10 batman sri: All tests successful.
22:10 jberger LOCALE ALL THE THINGS!!!!
22:11 sri batman: +1
22:11 * batman pushes to master
22:11 good_news_everyon joined #mojo
22:11 good_news_everyon [mojo] jhthorsen pushed 1 new commit to master: https://git.io/vgrvg
22:11 good_news_everyon mojo/master a1d482f Jan Henning Thorsen: Optimized most used Mojo::Header methods...
22:11 good_news_everyon left #mojo
22:12 orev when I run my app like: "./myapp routes" I'm getting: qq{Unknown command "development", maybe you need to install it?}
22:12 sri batman++
22:12 * batman feels useful
22:12 batman and it feels goooooood
22:13 batman ;)
22:13 * batman will try out https://gist.github.com/jhthorsen/9744e3dec887e89f50be next time
22:14 * batman will now go and fight crime!
22:14 batman be back tomorrow
22:15 jberger batman++
22:16 jberger orev: are you pushing things to @ARGV?
22:16 jberger or popping them?
22:16 orev jberger: no
22:17 jberger is this trying to do the single-file stuff?
22:18 orev jberger: no, I moved the command to an external file and set use lib
22:18 jberger hmmm
22:18 orev I'm just trying routes because that's supposed to already be there
22:19 jberger did you change the command namespaces?
22:20 orev I removed that
22:20 orev I am doing this though: app->start( $CONFIG->{app_mode} );.  app_mode is development
22:20 jberger ah, don't do that
22:20 good_news_everyon joined #mojo
22:20 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgrJ4
22:20 good_news_everyon mojo/master 175e3bf Sebastian Riedel: a few more header tests
22:20 good_news_everyon left #mojo
22:21 orev how do I specify the mode to run the app in?
22:21 jberger -m
22:21 jberger or MOJO_MODE=
22:21 sri or --mode
22:22 * pink_mist whispers BEGIN { $ENV{MOJO_MODE}=... }
22:22 pink_mist (ok, since that was all caps it might not *look* like a whisper, but... :P)
22:22 jberger hahahha
22:23 sri you know what, i can't believe Mojo::Headers actually got optimized this time
22:23 sri the lesson here is clearly that i just have to keep nagging :D
22:23 * jberger yells ᵃˡˡ ᵍˡᵒʳʸ ᵗᵒ ᵗʰᵉ ʰʸᵖⁿᵗᵒᵃᵈ
22:23 orev I'd like to have the mode in a config file.  how about app->mode( $CONFIG->{app_mode} ); app->start; ?
22:24 pink_mist jberger: lol :P
22:25 jberger orev: there's an order of operations problem there
22:25 orev jberger: yeah, that's what I was worried about
22:25 jberger and btw, mode is a nice way to choose which config file to load
22:25 jberger myapp.development.conf
22:25 orev sometimes there's too much magic in here!
22:26 jberger note also that development is the default mode for everything but hypnotoad/prefork
22:26 orev I need to load the config using mojo before I can use BEGIN, so that's out too
22:27 jberger where does your config come from?
22:27 jberger is it using the config plugin?
22:27 jberger if not, you could override your app's mode method
22:27 orev yes, config plugin
22:28 jberger which means its loaded during startup
22:28 jberger read this: http://mojolicious.org/perldoc/Mojolicious#mode
22:28 jberger clearly that's not gonna work
22:29 orev yeah, will move to app startup script then
22:29 orev will probably run in development mode for a while anyway
22:29 orev my custom commands are working now though :)
22:29 jberger yay
22:30 jberger it isn't a common thing around here to have your configuration file pick your mode
22:30 jberger most often the other way around
22:30 sri understatement, i've never seen it
22:31 sri and i've been around a long time ;p
22:31 good_news_everyon joined #mojo
22:31 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgrkk
22:31 good_news_everyon mojo/master 76a10ae Sebastian Riedel: slightly more consistent naming
22:31 good_news_everyon left #mojo
22:32 sri to make it work you'd have to redesign the startup process basially
22:32 sri https://github.com/kraih/mojo/blob/master/lib/Mojolicious.pm#L154
22:34 orev any thoughts on adding something like https://metacpan.org/pod/Short::URL to mojo::util?  or does it already exist?
22:36 sri what in mojolicious core would use that?
22:37 orev I'm looking at it to be able to keep urls short for users.  not a shortening service, just a way to keep longer integers smaller
22:37 orev maybe not universal enough for inclusion
22:41 jberger orev: mojo likes to keep the core lean
22:42 jberger my first interaction with #mojo was asking to add a Term::ReadKey so that Mojolicious::Command::cpanify could read a password without echoing to the terminal
22:42 pink_mist orev: you can always make it into a plugin
22:42 jberger looking back on it ... hahahefhhafhaihhiadhgaihspihahahhahhhahaa
22:43 pink_mist ... I wonder why I came here the first time 0_o I have no idea
22:43 pink_mist and it wasn't really that long ago
22:43 orev hmm, are helpers available inside a command?
22:43 sri fresh profiling data, if anyone else wants to give it a try http://mojolicious.org/nytprof/index.html
22:44 sri jberger: lol
22:48 jberger actually, crab liked it! https://github.com/kraih/mojo/issues/394
22:48 jberger and that wasn't my first interaction actually
22:48 jberger first I can find is this: http://irclog.perlgeek.de/mojo/2012-07-05#i_5787965
22:50 sri oh noes, i totally ignored you :o
22:50 jberger :s
22:51 jberger seems like that must have been longer ago than that
22:51 jberger the discussion around the prompt thing is funny
22:51 jberger I wasn't a regular around IRC yet
22:51 jberger http://irclog.perlgeek.de/mojo/2012-10-15#i_6063987
22:51 sri to be fair, that was before hypnotoad was running like clockwork, so there was smoke coming out of my ears thinking about how to make stuff work :)
22:52 sri damn, we've come so far since then
22:52 jberger true
22:53 sri that Mojolicious::Controller::rendered so high up seems sketchy http://mojolicious.org/nytprof/index.html
22:54 sri there shouldn't be too much going on actually
23:02 sri hmm
23:02 sri apparently this line is crazy expensive https://github.com/kraih/mojo/blob/master/lib/Mojolicious/Controller.pm#L206
23:02 sri http://mojolicious.org/nytprof/lib-Mojolicious-Controller-pm-197-line.html#206
23:06 asarch joined #mojo
23:08 jberger mostly the sprintf?
23:09 sri been thinking about deactivating the whole block https://gist.github.com/anonymous/831e983fce089a5d23d4
23:09 sri no timing overhead if there's no debug logging
23:10 sri it's in Mojoliicous.pm to prevent $stash->{'mojo.started'}
23:10 sri which in turn prevents the block in rendered
23:11 sri hello.pl goes from 1133 rps to 1222 rps
23:13 sri hmm, it does mess up testing a little though
23:13 sri since even without logging the events in Mojo:Log would still fire
23:15 sri jberger: maybe there's smaller optimizations to be made
23:15 sri like replacing the sprintf
23:16 jberger why even sprintf it there?
23:17 * sri shrugs
23:17 jberger to test if its equal to 0?
23:17 sri cargo culted?
23:18 jberger it is used to compute rps and then gets string interpolated
23:18 jberger I'd just try it without sprintf at all on that line
23:19 sri seems to work
23:21 good_news_everyon joined #mojo
23:21 good_news_everyon [mojo] kraih pushed 1 new commit to master: https://git.io/vgrGQ
23:21 good_news_everyon mojo/master 2d98637 Sebastian Riedel: maybe there is no need for sprintf
23:21 good_news_everyon left #mojo
23:22 jberger did it help the profile?
23:22 sri running it right now
23:22 jberger it might just shift the slowdown to the string interpolation
23:22 sri takes time ;p
23:22 jberger then again sprintf is not the same as string interpolation
23:23 jberger because of round-half-to-even which I don't think bare string interpolation cares aobut
23:23 sri there's somethign sketchy, just not sure yet what exactly
23:24 sri yea, does change the results Oo
23:24 sri syncing nytprof data
23:25 sri so much rendered drops down a spot
23:26 sri http://mojolicious.org/nytprof/index.html
23:26 jberger really, it looks like my prediction was right and the time just moved to line 211
23:27 sri oh, i did not look at the time spent there
23:28 sri Mojolicious::dispatch is higher now though
23:28 jberger 19.9 vs 39.4
23:29 jberger line 208 went up too
23:29 jberger so sprintf was basically precalculating the PV value
23:31 jberger I'm a little surprised to see that the math times got longer too
23:31 jberger maybe it precalculated some math internals too?
23:33 jberger ¯\_(ツ)_/¯
23:34 sri well, it has been there from the start :o
23:34 sri https://github.com/kraih/mojo/commit/a8d994740b6194db312fc091c8719b1d7c799f36
23:35 sri definitely cargo culted from somewhere
23:35 cfedde there is a kind of person that keeps their blog up to date.  I have enough trouble just cut-n-paste commands into my tickets.
23:37 jberger Seeing "add timer" is like seeing "add GET route"
23:38 sri back then there was no event loop :)
23:38 jberger :o
23:39 sri you're going to fall off your chair when you see the early user agent https://github.com/kraih/mojo/blob/a8d994740b6194db312fc091c8719b1d7c799f36/lib/Mojo/Client.pm#L341
23:40 sri there was spin method!
23:40 jberger deposit_connection?? spin??
23:40 sri it's hilarious how bad it was
23:41 sri gotta make a lot of mistakes to learn how to do it right
23:41 jberger The documentation is a bit lacking too, what the heck was spin?
23:41 sri basically an inside out event loop if i remember correctly
23:42 sri you ->spin until somethig happens and then check the transactions you're processing
23:42 jberger I .... uhhhhh ...
23:42 sri :D
23:43 sri think it was like Mojo::IOLoop->one_tick
23:43 jberger <3 Mojo::UserAgent
23:43 jberger That's my response
23:44 sri allright, enough nostalgia for today
23:46 sri those Time::HiRes calls really add up
23:48 jberger Oh really? I was gonna add one more
23:49 sri (╯°□°)╯︵ ┻━┻)
23:49 jberger I recalled that it was bdfoy who introduced me to mojo via the UserAgent here http://stackoverflow.com/questions/7008570/whats-wrong-with-my-perl-script/7010485#comment8371683_7010485
23:49 sri \o/
23:50 sri lol "I wish someone would reinvent the XML parser."
23:50 sri we got you!
23:52 jberger Yup
23:52 sri too Mojo::DOM a few years to grow up too
23:52 sri *took
23:52 jberger ok now we can </nostalgia>
23:53 sri every now and then i still want to support those super edgy special cases like bare "</br>" and "</p>"
23:54 sri (both are supposed to become start tags)
23:54 jberger really, I thought those were <br/>
23:54 jberger and <p/>
23:55 sri "</p>" becomes "<p></p>"
23:55 jberger oh I thought that's what you meant
23:55 jberger so bare </p> is supposed to become a bare <p> ??
23:55 sri apparently people have been using it for newlines since the 90s
23:56 jberger I found plenty of <p/> in the code I took over at the previous job
23:56 sri "</br>" becomes "<br>" i think
23:56 sri <p/> is fine
23:56 Grinnz_ <p/> is just XML
23:56 jberger the br transform is ok
23:56 jberger if </p> becomes <p> thats really odd
23:56 Grinnz_ </p> with no start tag is a workaround for bad markup
23:56 sri not <p>, but <p></p>
23:59 jberger ok so a bare </p> becomes a bare <p/>
23:59 sri this regex seems not very optimized http://mojolicious.org/nytprof/lib-Mojo-Headers-pm-78-line.html#107

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