[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 01/15] audio: replace open-coded buffer arithmetic
From: |
Gerd Hoffmann |
Subject: |
Re: [PATCH v2 01/15] audio: replace open-coded buffer arithmetic |
Date: |
Wed, 26 Jan 2022 09:48:25 +0100 |
Hi,
> > > --- a/audio/audio_int.h
> > > +++ b/audio/audio_int.h
> > > @@ -266,6 +266,12 @@ static inline size_t audio_ring_dist(size_t dst,
> > > size_t src, size_t len)
> > > return (dst >= src) ? (dst - src) : (len - src + dst);
> > > }
> > You haven't touched this function, but while I am looking at it, all
> > function
> > arguments are unsigned. So probably modulo operator might be used to get rid
> > of a branch here.
>
> That would be "return (len - dist + pos) % len;" but on my x86_64 system I
> always prefer a conditional move instruction to a 64 bit integer division
> instruction.
Why? Performance?
Don't underestimate the optimizer of a modern compiler. In many cases
it simply isn't worth the effort. Better optimize the code for humans,
i.e. make it easy to read and understand.
take care,
Gerd
- [PATCH v2 00/15] reduce audio playback latency, Volker Rümelin, 2022/01/22
- [PATCH v2 02/15] audio: move function audio_pcm_hw_clip_out(), Volker Rümelin, 2022/01/22
- [PATCH v2 03/15] audio: add function audio_pcm_hw_conv_in(), Volker Rümelin, 2022/01/22
- [PATCH v2 04/15] audio: inline function audio_pcm_sw_get_rpos_in(), Volker Rümelin, 2022/01/22
- [PATCH v2 07/15] audio: copy playback stream in sequential order, Volker Rümelin, 2022/01/22
- [PATCH v2 06/15] jackaudio: use more jack audio buffers, Volker Rümelin, 2022/01/22
- [PATCH v2 08/15] audio: add pcm_ops function table for capture backend, Volker Rümelin, 2022/01/22
- [PATCH v2 10/15] audio: restore mixing-engine playback buffer size, Volker Rümelin, 2022/01/22
- [PATCH v2 05/15] paaudio: increase default latency to 46ms, Volker Rümelin, 2022/01/22