Skip to content
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

Screenshot processing #22

Closed
florczakraf opened this issue Jul 13, 2016 · 13 comments
Closed

Screenshot processing #22

florczakraf opened this issue Jul 13, 2016 · 13 comments
Labels

Comments

@florczakraf
Copy link
Contributor

Hey. Recently I tried to make use of the sv_screenshotArrivedCmd. I wrote a python script to extract meta-data from the screenshot and draw it on the picture itself. Script does it's job, however I experience the lag on the server each time a new screenshot has arrived. It's local lag -- not shared between other game servers I run on the same machine (i.e. only server that's processing screenshots at the time is affected). The lag is noticeable even without lagometer on -- server freezes for a moment so players experience teleporting.

Here's short video to visualize the issue: https://www.youtube.com/watch?v=FgIVT6_pOhc (you can see spikes on the lagometer at the moment of console outputting Screenshot for client ... saved to screenshots/...).

Here are my questions:

  1. Have you actually tested this feature? 😏
  2. Is it normal that there is such a huge overhead for creating new process with execv? (I couldn't find reliable source on the net.)
  3. Am I doing something wrong?

More info:
I can provide my script if needed, although the issue exists even with empty python script:

#!/usr/bin/python3
if __name__ == '__main__':
   pass

or this c program 😏:

int main()
{
    return 0;
}
@IceNinjaman
Copy link
Collaborator

Hi there,
I have to admit to not having tested this feature. Isn't it fork() + execv() ?
If your cod4server process start to lag it is probably caused by a function call which does block for some time. Maybe fork() is doing this? Although fork() is part of many daemons you can find on *nix systems. There a little bit lag is maybe not the issue? I don't really know how to do it better.
Creating a new thread to fork() then?

@T-Maxxx
Copy link
Contributor

T-Maxxx commented Jul 16, 2016

fork() and execv() are very expensive operations. But yeah, forking in other thread should do the trick.
https://github.com/D4edalus/CoD4x_Server/blob/master/src/unix/sys_unix.c#L108

@D4edalus
Copy link
Contributor

imho it would be best to just have a plugin callback

2016-07-17 0:30 GMT+02:00 Max notifications@github.com:

fork() and execv() are very expensive operations. But yeah, forking in
other thread should do the trick.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/D4edalus/CoD4x_Server/issues/22#issuecomment-233154384,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ARP0TDtGF4bzkqYMyFoUg1t9lM4y6K3Wks5qWVuHgaJpZM4JLnTg
.

@IceNinjaman
Copy link
Collaborator

In current version it is replaced by creating a new thread and invoking system(). Would be nice to know if it works and if it works better. You need however this library for screenshots you can find on forum.

@florczakraf
Copy link
Contributor Author

Alright, I will try to give it a go tonight.

@florczakraf
Copy link
Contributor Author

Did not help at all (tested with empty c program as screenshot processor). I noticed that you now wait till player sees someone to take a screenshot 👍

@IceNinjaman
Copy link
Collaborator

You are saying it still doing lag?

@florczakraf
Copy link
Contributor Author

That's exactly what I'm saying.

On 11 August 2016 at 02:33, IceNinjaman notifications@github.com wrote:

You are saying it still doing lag?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/D4edalus/CoD4x_Server/issues/22#issuecomment-239045749,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIna09NFmEqsAe17tFS4B0DGu4H5D2qVks5qem33gaJpZM4JLnTg
.

@IceNinjaman
Copy link
Collaborator

Okay well then I have no idea how to improve it. Is your host weak in general?

@florczakraf
Copy link
Contributor Author

Don't think so.
CPU: Intel Xeon E3 1245v2 4 cores/ 8 threads 3.4 GHz+
RAM: 32GB DDR3
DISK: 2 x 2 TB SATA (soft raid)
We host some cod4 server, ts, some webtools, and a minecraft server there. Low resource usage.

@IceNinjaman
Copy link
Collaborator

Okay I still can't do anything if launching a new process does load the whole system so much.

@florczakraf
Copy link
Contributor Author

florczakraf commented Aug 12, 2016

It doesn't load whole system, that's the point. It only makes the server that's currently receiving screenshots lag. Anyway, thanks for trying.

@D4edalus D4edalus added the bug label Aug 21, 2016
@D4edalus
Copy link
Contributor

D4edalus commented Sep 6, 2016

D4edalus@8a0a312

added a plugin callback to enable a more leightweight screenshot processing and avoid manual parsing.

@D4edalus D4edalus closed this as completed Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants