lpereira / lwan

Experimental, scalable, high performance HTTP server

Home Page:https://lwan.ws

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Memory Question

ruiluis opened this issue · comments

hi i am looking at your project.. now i want to make some request processing and i am currently doing a malloc for creating an auxiliary structure. i notice the presence of a coro_malloc.. can i follow my approach or is advisable to use the coro functions to create the structure that is only used by the request..

Use coro_malloc(). Not only it's more convenient (you don't have to worry about freeing it -- in fact, don't free the pointer returned by it), if the coroutine is killed for whatever reason (e.g. connection closed by the other end), the memory is freed for you automatically. If memory is allocated with malloc(), it may leak.

Also, coro_malloc() has an optimization for repeated calls from the same coroutine where the cost to malloc() is amortized by using a fast allocation technique.

Changed to coro.. and works well.. another issue.. the cache its viable for supporting millions of entries or should i use my own cache implementation?

I've never had millions of entries in the cache. It should work, but I have no clue how it will perform. I would appreciate patches improving performance, of course!

Closing this issue. Feel free to reopen or open another one.