[alsa-devel] PulseAudio and SNDRV_PCM_INFO_BATCH

Alexander E. Patrakov patrakov at gmail.com
Fri Jun 12 15:43:47 CEST 2015


12.06.2015 17:32, Arun Raghavan wrote:
> On 12 June 2015 at 17:59, Arun Raghavan <arun at accosted.net> wrote:
>> Hi folks,
>> I'd like to bring this one up again, since we are currently in the
>> sub-optimal position of forcing ~100 ms latency on USB devices. The
>> original thread is here --
>> http://mailman.alsa-project.org/pipermail/alsa-devel/2013-December/069666.html
>
> While we sort this out, though, is there an upper bound on the USB
> transfer size (that we could then use a rewind safety margin)? We
> might be able to use this as a workaround till this can be fixed
> properly.

Hello Arun,

thanks for bringing up the issue again. However, I think that the "~100 
ms latency on batch cards" problem can and should also be solved from 
the other end, independently from the USB special case. Namely, I think 
that the default buffer and period sizes that PulseAudio selects are way 
too conservative. The power-saving argument was used in the past as a 
justification, and I am calling for a reevaluation. Here is why.

1. Android's AudioFlinger uses 2 periods, 5 ms each. It is a mobile OS, 
and the developers think it is good enough.

2. I have measured the battery life time of my SandyBridge-based laptop 
and found that, with pure ALSA on the hw:0 device, a similar low-latency 
setup loses less than 5% of the battery life (935 seconds were lost out 
of 25742). With PulseAudio, the difference is worse, but let's treat 
this as a missed optimization in PulseAudio.

Let me make my viewpoint more explicit: from now on, I will reject CPU 
usage measurements as an evidence for "real power-saving problems", 
unless a correlation factor between them and the battery life has been 
also measured on the same device. Direct measurements of the battery 
life in reproducible conditions are of course welcome.

Raw data for the experiment (2) with pure ALSA are attached. The first 
column is the time since boot, in seconds, and the second column is the 
remaining energy in the battery, in microwatt-hours, as reported in the 
energy_now sysfs attribute. report-1428125745.txt is with 
--period-size=44100 --buffer-size=88200, report-1428161181.txt is with 
--buffer-size=440 --period-size=220, the test file is a 44100 Hz, S16, 
stereo wav file.

To guarantee the reproducibility of this experiment, the entire system 
(Gentoo stage3 plus PulseAudio plus laptop-mode-tools) has been put in 
the initramfs, together with a script that turns off the backlight and 
then repeatedly plays a wav file from the same initramfs through aplay. 
The wi-fi card has been turned off with a hardware toggle. So everything 
(including the SSD) during the test is unused, except CPU, memory, and 
the onboard sound card. That's why the test exhibits unrealistically 
long battery life.

If my result gets confirmed on a laptop that is not a former flagman 
from Sony, then I would argue for the following:

1. Change of the default buffer and period sizes for batch cards in 
PulseAudio to values that represent, on modern hardware, say, 2.5% of 
battery life reduction as compared to very large periods.

2. Limiting of the sleep time in the timer-based scheduling logic to a 
similar value. If this ends up below 30 ms, then we can simplify 
PulseAudio by removing all traces of the rewind logic.

-- 
Alexander E. Patrakov
-------------- next part --------------
5 38590000
80 38590000
155 38590000
230 38590000
305 38590000
380 38590000
456 38590000
531 38590000
606 38590000
681 38590000
756 38590000
831 38540000
906 38450000
981 38380000
1056 38310000
1131 38220000
1206 38150000
1281 38080000
1356 37980000
1431 37920000
1506 37850000
1581 37750000
1656 37710000
1731 37620000
1806 37570000
1881 37500000
1956 37410000
2031 37360000
2106 37270000
2181 37220000
2256 37130000
2331 37060000
2406 37000000
2481 36920000
2556 36850000
2631 36790000
2706 36720000
2781 36640000
2856 36550000
2931 36510000
3006 36410000
3082 36360000
3157 36230000
3232 36090000
3307 35910000
3382 35790000
3457 35680000
3532 35490000
3607 35380000
3682 35190000
3757 35060000
3832 34890000
3907 34740000
3982 34630000
4057 34510000
4132 34330000
4207 34210000
4282 34100000
4357 33910000
4432 33800000
4507 33680000
4582 33520000
4657 33380000
4732 33240000
4807 33120000
4882 32970000
4957 32760000
5032 32710000
5107 32590000
5182 32480000
5258 32330000
5333 32220000
5408 32100000
5483 31990000
5558 31880000
5633 31690000
5708 31550000
5783 31440000
5858 31310000
5933 31200000
6008 31090000
6083 30950000
6158 30840000
6233 30710000
6308 30600000
6383 30460000
6458 30350000
6533 30230000
6608 30110000
6683 30000000
6758 29810000
6833 29690000
6908 29580000
6983 29470000
7058 29330000
7133 29220000
7208 29070000
7283 28960000
7358 28840000
7434 28730000
7509 28600000
7584 28470000
7659 28350000
7734 28240000
7809 28130000
7884 27980000
7959 27870000
8034 27750000
8109 27640000
8184 27520000
8259 27380000
8334 27220000
8409 27080000
8484 26960000
8559 26850000
8634 26730000
8709 26550000
8784 26430000
8859 26320000
8934 26170000
9009 26060000
9084 25870000
9159 25720000
9234 25570000
9309 25460000
9384 25270000
9459 25160000
9534 24740000
9610 24600000
9685 24490000
9760 24380000
9835 24140000
9910 23930000
9985 23720000
10060 23510000
10135 23230000
10210 22980000
10285 22780000
10360 22570000
10435 22330000
10510 22120000
10585 22010000
10660 21800000
10735 21590000
10810 21380000
10885 21290000
10960 21060000
11035 20760000
11110 20520000
11185 20350000
11260 20200000
11335 20110000
11410 19900000
11485 19790000
11560 19690000
11635 19580000
11711 19370000
11786 19260000
11861 19050000
11936 18950000
12011 18840000
12086 18730000
12161 18510000
12236 18390000
12311 18300000
12386 18190000
12461 18090000
12536 17880000
12611 17860000
12686 17770000
12761 17560000
12836 17490000
12911 17350000
12986 17330000
13061 17240000
13136 17130000
13211 17010000
13286 16920000
13361 16870000
13436 16770000
13511 16710000
13586 16590000
13661 16590000
13736 16450000
13811 16380000
13886 16380000
13962 16170000
14037 16060000
14112 15960000
14187 15960000
14262 15850000
14337 15730000
14412 15680000
14487 15640000
14562 15640000
14637 15530000
14712 15430000
14787 15430000
14862 15320000
14937 15230000
15012 15170000
15087 15110000
15162 15020000
15237 15000000
15312 14900000
15387 14900000
15462 14790000
15537 14790000
15612 14700000
15687 14570000
15762 14510000
15837 14460000
15912 14360000
15987 14270000
16063 14250000
16138 14130000
16213 14040000
16288 13930000
16363 13850000
16438 13830000
16513 13720000
16588 13630000
16663 13550000
16738 13510000
16813 13440000
16888 13400000
16963 13350000
17038 13300000
17113 13230000
17188 13160000
17263 13120000
17338 13020000
17413 12980000
17488 12910000
17563 12790000
17638 12630000
17713 12540000
17788 12470000
17863 12380000
17938 12310000
18013 12210000
18088 12120000
18163 12010000
18239 11930000
18314 11820000
18389 11700000
18464 11610000
18539 11500000
18614 11380000
18689 11240000
18764 11120000
18839 11010000
18914 10890000
18989 10760000
19064 10480000
19139 10360000
19214 10250000
19289 10080000
19364 9920000
19439 9760000
19514 9650000
19589 9480000
19664 9370000
19739 9200000
19814 9050000
19889 8880000
19964 8710000
20039 8580000
20114 8440000
20189 8180000
20264 8050000
20339 7900000
20415 7840000
20490 7700000
20565 7560000
20640 7450000
20715 7350000
20790 7220000
20865 7120000
20940 7000000
21015 6860000
21090 6730000
21165 6600000
21240 6520000
21315 6380000
21390 6280000
21465 6130000
21540 6030000
21615 5890000
21690 5790000
21765 5680000
21840 5590000
21915 5450000
21990 5320000
22065 5190000
22140 5060000
22215 4960000
22290 4850000
22365 4710000
22440 4570000
22516 4480000
22591 4320000
22666 4230000
22741 4110000
22816 3970000
22891 3830000
22966 3740000
23041 3670000
23116 3620000
23191 3550000
23266 3490000
23341 3420000
23416 3340000
23491 3300000
23566 3250000
23641 3160000
23716 3090000
23791 3040000
23866 3000000
23941 2930000
24016 2850000
24091 2810000
24166 2740000
24241 2700000
24316 2630000
24391 2550000
24466 2510000
24541 2420000
24616 2350000
24692 2250000
24767 2210000
24842 2100000
24917 2000000
24992 1910000
25067 1800000
25142 1650000
25217 1610000
25292 1540000
25367 1470000
25442 1400000
25517 1310000
25592 1190000
25667 1080000
25742 930000
-------------- next part --------------
5 38590000
80 38590000
155 38590000
229 38590000
304 38590000
379 38590000
454 38590000
528 38590000
603 38590000
678 38590000
752 38590000
827 38590000
902 38520000
976 38450000
1051 38360000
1126 38260000
1200 38200000
1275 38130000
1350 38030000
1425 37960000
1499 37870000
1574 37810000
1649 37710000
1723 37660000
1798 37570000
1873 37500000
1947 37410000
2022 37340000
2097 37270000
2172 37200000
2246 37110000
2321 37060000
2396 36960000
2470 36870000
2545 36830000
2620 36740000
2694 36640000
2769 36600000
2844 36510000
2919 36460000
2993 36360000
3068 36190000
3143 36060000
3217 35880000
3292 35720000
3367 35580000
3441 35460000
3516 35280000
3591 35120000
3666 34980000
3740 34870000
3815 34680000
3890 34570000
3964 34380000
4039 34250000
4114 34080000
4188 33950000
4263 33800000
4338 33660000
4413 33540000
4487 33360000
4562 33240000
4637 33120000
4711 33010000
4786 32870000
4861 32710000
4936 32570000
5010 32460000
5085 32330000
5160 32220000
5234 32030000
5309 31920000
5384 31800000
5458 31670000
5533 31550000
5608 31390000
5683 31310000
5757 31140000
5832 31010000
5907 30900000
5981 30760000
6056 30650000
6131 30540000
6205 30410000
6280 30230000
6355 30110000
6430 29970000
6504 29860000
6579 29750000
6654 29600000
6728 29510000
6803 29390000
6878 29220000
6953 29090000
7027 28980000
7102 28840000
7177 28730000
7251 28600000
7326 28490000
7401 28370000
7475 28190000
7550 28130000
7625 28010000
7700 27850000
7774 27750000
7849 27590000
7924 27450000
7998 27340000
8073 27220000
8148 27060000
8222 26920000
8297 26810000
8372 26680000
8447 26510000
8521 26380000
8596 26200000
8671 26090000
8745 25900000
8820 25790000
8895 25640000
8970 25490000
9044 25300000
9119 24930000
9194 24760000
9268 24630000
9343 24460000
9418 24320000
9492 24120000
9567 23810000
9642 23600000
9717 23380000
9791 23170000
9866 22870000
9941 22630000
10015 22420000
10090 22210000
10165 22000000
10239 21840000
10314 21630000
10389 21470000
10464 21270000
10538 21150000
10613 20720000
10688 20630000
10762 20420000
10837 20310000
10912 20100000
10986 19990000
11061 19780000
11136 19660000
11211 19570000
11285 19360000
11360 19250000
11435 19080000
11509 18950000
11584 18830000
11659 18710000
11734 18500000
11808 18410000
11883 18290000
11958 18180000
12032 18090000
12107 17970000
12182 17880000
12256 17780000
12331 17560000
12406 17460000
12481 17420000
12555 17350000
12630 17230000
12705 17090000
12779 17030000
12854 16910000
12929 16910000
13003 16820000
13078 16690000
13153 16610000
13228 16560000
13302 16520000
13377 16310000
13452 16180000
13526 16180000
13601 16070000
13676 15960000
13751 15960000
13825 15860000
13900 15750000
13975 15710000
14049 15650000
14124 15610000
14199 15540000
14273 15450000
14348 15430000
14423 15330000
14498 15220000
14572 15220000
14647 15120000
14722 15120000
14796 15010000
14871 14920000
14946 14900000
15020 14800000
15095 14710000
15170 14690000
15245 14560000
15319 14470000
15394 14430000
15469 14360000
15543 14260000
15618 14170000
15693 14060000
15768 13940000
15842 13940000
15917 13850000
15992 13730000
16066 13690000
16141 13620000
16216 13580000
16290 13500000
16365 13450000
16440 13390000
16515 13300000
16589 13220000
16664 13180000
16739 13110000
16813 13020000
16888 12940000
16963 12740000
17037 12670000
17112 12620000
17187 12510000
17262 12390000
17336 12300000
17411 12230000
17486 12110000
17560 12000000
17635 11910000
17710 11790000
17784 11680000
17859 11580000
17934 11440000
18009 11300000
18083 11190000
18158 11040000
18233 10910000
18307 10790000
18382 10510000
18457 10400000
18532 10230000
18606 10090000
18681 9910000
18756 9750000
18830 9590000
18905 9470000
18980 9310000
19054 9150000
19129 8960000
19204 8800000
19279 8640000
19353 8470000
19428 8360000
19503 8100000
19577 7980000
19652 7850000
19727 7700000
19801 7640000
19876 7490000
19951 7360000
20026 7240000
20100 7100000
20175 7020000
20250 6890000
20324 6760000
20399 6620000
20474 6500000
20549 6360000
20623 6270000
20698 6110000
20773 6020000
20847 5870000
20922 5760000
20997 5620000
21071 5550000
21146 5420000
21221 5270000
21296 5140000
21370 5020000
21445 4930000
21520 4780000
21594 4670000
21669 4530000
21744 4420000
21818 4270000
21893 4140000
21968 4020000
22043 3890000
22117 3800000
22192 3720000
22267 3650000
22341 3610000
22416 3540000
22491 3460000
22566 3400000
22640 3330000
22715 3260000
22790 3190000
22864 3140000
22939 3070000
23014 3010000
23088 2930000
23163 2860000
23238 2820000
23313 2750000
23387 2680000
23462 2610000
23537 2540000
23611 2450000
23686 2380000
23761 2310000
23835 2220000
23910 2120000
23985 2010000
24060 1920000
24134 1800000
24209 1670000
24284 1590000
24358 1520000
24433 1480000
24508 1390000
24582 1290000
24657 1180000
24732 1030000
24807 900000


More information about the Alsa-devel mailing list