Re: [mongrel2] Profiler filter for mongrel2
- From:
- Eimantas Vaiciunas
- Date:
- 2011-12-21 @ 18:00
All the best,
Eimantas Vaiciunas
On Dec 21, 2011, at 6:55 PM, Dalton Barreto wrote:
> 2011/12/21 Eimantas Vaiciunas <eimantas@vaiciunas.info>:
>> Hello all
>>
>> I have hacked up proof-of-concept profiler filter for Mongrel2. It's dead
>> simple, it measures time between REQ_RECV and RESP_SENT.
>>
>> The code can be found here: http://pastebin.com/HaxT2iC5
>>
>> Since this is just a proof of concept and I'm still learning - I'd like to
>> get early feedback on how I should continue working on this thing, what
>> things should I consider (thread safety, streaming (thanks to IRC feedback)
>> and any possible edge cases).
>>
>
> That's a good idea!! Congrats!
>
> I was reading the code very briefly and maybe you will need to store
> the RECV/SENT time for each connection separately, using its ID for
> instance.
>
> I didn't confirm this, but since mongrel2 only loads each filter once,
> I think that the current code will be confused by two connections
> arriving
> with a very close RECV time, and If the first connection finishes
> before the second, the filter would calculate the total time using the
> RECV of the
> second conn and the SENT of the first.
>
> This happens because mongrel2 calls the same funciton, only with
> different parameters (the Connection *conn, for example).
Right, so I should construct some sort of per-connection storage for
profiling information.
Is there some sort of library already added to mongrel2 for doing this
sort of thing?
> Please note that I didn't run the filter yet, I just took a quick look
> ate the code!
>
> Again, congratulations and happy hacking!
>
> --
> Dalton Barreto
> http://daltonmatos.com
Re: [mongrel2] Profiler filter for mongrel2
- From:
- Dalton Barreto
- Date:
- 2011-12-21 @ 18:13
2011/12/21 Eimantas Vaiciunas <eimantas@vaiciunas.info>:
>
> Right, so I should const ruct some sort of per-connection storage for
> profiling information.
>
Yes.
> Is there some sort of library already added to mongrel2 for doing this sort
> of thing?
>
Mongrel2 it self uses functions from src/adt/array.{h,c} to store all
active connections. Take a look at these and check if you can use
them. I think a simple array will solve the problem.
--
Dalton Barreto
http://daltonmatos.com