Log xruns from command line?

Optimize your system for ultimate performance.

Moderators: MattKingUSA, khz

Post Reply
to7m
Established Member
Posts: 4
Joined: Sun Nov 13, 2016 6:52 am

Log xruns from command line?

Post by to7m »

Hi all,

I'm looking to do some xrun testing without a desktop environment for the purpose of taking DE problems out of the equation, so any hints on how to go about that would be great. The only methods I've seen so far involve GUIs.

Thanks,
Tom

gimmeapill
Established Member
Posts: 546
Joined: Thu Mar 12, 2015 8:41 am

Re: Log xruns from command line?

Post by gimmeapill »

No idea how to actually count xruns from the CLI, but wondering about your test: what audio console application are you going to put some load on the system? Just measuring xruns on a system that is running idle is probably to going to tell you much...

The closest thing I can think of is cyclictest (part of the rt-tests suite):
https://rt.wiki.kernel.org/index.php/Cyclictest

It will catch latency peaks while simulating a workload, which is essentially the same thing...

gimmeapill
Established Member
Posts: 546
Joined: Thu Mar 12, 2015 8:41 am

Re: Log xruns from command line?

Post by gimmeapill »

Actually, just starting jackd from the command line in verbose mode with "-v" should do the trick and spit out some xrun messages.
(Sorry I'm not in front of my linux box to confirm)

tramp
Established Member
Posts: 1617
Joined: Mon Jul 01, 2013 8:13 am

Re: Log xruns from command line?

Post by tramp »

. . or write a little app witch counts the xruns.

xruncounter.c

Code: Select all

#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>

#include <jack/jack.h>

/*   gcc -Wall xruncounter.c -lm `pkg-config --cflags --libs jack` -o xruncounter */

jack_client_t *client;


void
jack_shutdown (void *arg)
{
	exit (1);
}

int jack_xrun_callback(void *arg) 
{
	/* count xruns */
	static int xruns = 0;
	xruns += 1;
	fprintf (stderr, "xrun %i \n", xruns);
	return 0;
}

void
signal_handler (int sig)
{
	jack_client_close (client);
	fprintf (stderr, " signal received, exiting ...\n");
	exit (0);
}

int
main (int argc, char *argv[])

{

	if ((client = jack_client_open ("xruncounter", JackNullOption, NULL)) == 0) {
		fprintf (stderr, "jack server not running?\n");
		return 1;
	}

	signal (SIGQUIT, signal_handler);
	signal (SIGTERM, signal_handler);
	signal (SIGHUP, signal_handler);
	signal (SIGINT, signal_handler);

	jack_set_xrun_callback(client, jack_xrun_callback, 0);
	jack_on_shutdown (client, jack_shutdown, 0);

	if (jack_activate (client)) {
		fprintf (stderr, "cannot activate client");
		return 1;
	}
	while (1) {
		usleep (100000);
	}

	jack_client_close (client);
	exit (0);
}
On the road again.

gimmeapill
Established Member
Posts: 546
Joined: Thu Mar 12, 2015 8:41 am

Re: Log xruns from command line?

Post by gimmeapill »

tramp you're overdoing it ;-)

Confirmed: Just running jackd from a terminal with whatever setting you have in .jackdrc will show xruns as they happen (-v is not even needed).

User avatar
CrocoDuck
Established Member
Posts: 1097
Joined: Sat May 05, 2012 6:12 pm
Contact:

Re: Log xruns from command line?

Post by CrocoDuck »

tramp wrote:. . or write a little app witch counts the xruns.
I was thinking of doing the same... but actually haven't got enough time (being a noob, it would require me 100 X the time). I recently coded a little algorithm at work to assess whether detected events of some kind are correlated to each other... just wondering whether that could be of some use with xruns stats...
Check my Linux audio experiments on my SoundCloud.
Browse my AUR packages.
Fancying a swim in the pond?

gimmeapill
Established Member
Posts: 546
Joined: Thu Mar 12, 2015 8:41 am

Re: Log xruns from command line?

Post by gimmeapill »

@Crocoduck: not sure if this can help with your project since he does it offline, but this chap has dissected xruns with lttng and latency_tracker:
http://lttng.org/blog/2016/01/06/monito ... latencies/

I had one embryonic package prepared to try this out, but never had time to push it further.
If you're interested, I'll happily hand it over as I'm really short on time those days:
https://aur.archlinux.org/packages/latency-tracker-git/

OK, and another thread that went off the rails - sorry OP, I'll stop there ;-)

User avatar
raboof
Established Member
Posts: 1690
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Contact:

Re: Log xruns from command line?

Post by raboof »

tramp wrote:. . or write a little app witch counts the xruns.
This is pretty neat, perhaps we should share it on github or so for easier collaboration/evolution?

Post Reply