sunng87 / handlebars-iron

Handlebars middleware for Iron web framework
MIT License
119 stars 20 forks source link

Is there way to use DirectorySource as MemorySource? #54

Closed mrLSD closed 7 years ago

mrLSD commented 7 years ago

Is there way to use DirectorySource as MemorySource?

I tested: https://github.com/sunng87/handlebars-iron/blob/master/examples/server.rs

wrk -t12 -c400 -d2s http://localhost:3000/mem
90k rps
wrk -t12 -c400 -d2s http://localhost:3000/
30k rps

I saw perfomance issue - I/O.

sunng87 commented 7 years ago

Hah, that's because the template for MemorySource in the example is significantly smaller and simpler than DirectorySource. Once you called reload on HandlebarsEngine, the templates will be loaded into memory and parsed, so there is no different between sources at runtime.

mrLSD commented 7 years ago

I done some research.My templates + layouts with really small logic significantly reduce perfomance, for example  from 90k rps to 15k rps.It's 6x slower.My question: is it perfomance issue?    21.11.2016, 15:20, "Ning Sun" notifications@github.com:Hah, that's because the template for MemorySource in the example is significantly smaller and simpler than DirectorySource. Once you called reload on HandlebarsEngine, the templates will be loaded into memory and parsed, so there is no different between sources at runtime.—You are receiving this because you authored the thread.Reply to this email directly, view it on GitHub, or mute the thread. 

sunng87 commented 7 years ago

I think this is reasonable. 90k rps is really really fast. At this level, any logic will add significant overhead to it. If you add some database logic to your handler, the overhead can be ignored.

And at the moment I haven't optimize render speed specifically. There is room for future improvement.

I will close this for now.