-
Notifications
You must be signed in to change notification settings - Fork 284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use timeFinalized? #1347
Comments
There is currently no hook for that specific place (probably applies to #1327). However, as long as
In case of multi-threaded request processing ( |
I'm exploring this. Currently it seems that the
|
The On the other hand, if you use My personal use of vibe.d doesn't involve using |
You are right, I assumed that we'd still have everything in a single memory pool, which is reclaimed by the GC, but the The other problem is that there is keep-alive, which renders the whole point pretty useless anyway. All those tasks would be called at the same time when the connection gets closed instead of after each request.
Usually this will work, but if you have for example compression + chunked output, there is no way to send the last chunk before existing the request handler scope. I think the
Right, a little GC use in particular will render any multi-threading attempts almost useless (Amdahl's law kicks in really soon). I usually only really use it for benchmark purposes. All actual services/apps are running single-threaded. Makes me think if it would be a good idea to add something like a |
Also ignores any redundant calls to it.
Now works like this:
|
I see. That should work. I'll try. Where do I pass In my case I want to have two threads (and two kinds of tasks). The first kind handles web requests and the second kind handles background jobs. The first one should not by handled by the same thread as the second one because I'll guess that slows down the first one. How would you achieve such a setup? |
Fork after listen should in theory work, it would reuse the same socket descriptor in that case, but I've never tried it. For the libevent backend, Regarding the background jobs, |
Yes, this is default in libasync as well.
If your background jobs are very intensive, might as well run them in a new process as well, it could even use std.process. Linux has some good mechanisms to schedule the CPU time on these background jobs. I think Sönke had a Task waiter for that? I would use |
Thanks. That works. Though On a related note: Any plans to give some fine grained control over the worker threads? Currently it creates |
Usually you would extract the parts of the
Joining tasks across threads isn't implemented, yet. Otherwise this would work, too:
The downside is that the request handler will have to block for the length of the background operation. If the response should instead be sent earlier, you have no choice but to copy the important bits in the request handler. |
I went with copying for now. |
Probably I'm doing it wrong. But you seemed to suggest that I keep vibe single threaded and fork off processes and let linux round robin the connections. So like
The thing is that the forked process dies with an libevent assertion:
So what's the trick? |
According to the libevent docs, this may require a call to Looks like forking will have to be a feature of the |
Many thanks. That works. Fixed some typos in your suggested code. The child process(es) execute now.
Then I see that a request may be handled by a different process. You may want to add a function reinit to the EventDriver interface. One thing though is strange. The forked child does not have vibe signal handling. I need to kill the child processes manually via SIGKILL. |
When a
HTTPServerResponse
is finalized (by callingfinalize()
) its memberm_timeFinalized
is set. I want to access it through timeFinalized(). The difficulty is I don't know how. Because the response is finalized by the driver. Do I start another task viarunTask
? I believe I tried that which resulted in a segfault. What do I do in case of multi-threading? I need to make sure that one task is finished (finalized) before the other is run. I read somewhere about signaling between fibers. Is that the way to go?The text was updated successfully, but these errors were encountered: