[spice-server,1/3] glz-encoder-dict: Remove useless __packed__ attribute

Submitted by Frediano Ziglio on July 22, 2019, 11:08 a.m.

Details

Message ID 20190722110841.31711-1-fziglio@redhat.com
State Accepted
Commit ecd0d70a3d7f80a5cacb308eb249fa594edbe37b
Headers show
Series "Series without cover letter" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

Frediano Ziglio July 22, 2019, 11:08 a.m.
The structure has no holes, adding this attribute could only
decrease efficiency.
Note that HashEntry structure is used for a large (8MB) array so
this won't affect much possible container size.

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
---
 server/glz-encoder-priv.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/server/glz-encoder-priv.h b/server/glz-encoder-priv.h
index 08dc007ce..7757f232c 100644
--- a/server/glz-encoder-priv.h
+++ b/server/glz-encoder-priv.h
@@ -76,7 +76,7 @@  struct WindowImageSegment {
 };
 
 
-struct  __attribute__ ((__packed__)) HashEntry {
+struct HashEntry {
     uint32_t image_seg_idx;
     uint32_t ref_pix_idx;
 };

Comments

ping

> 
> The structure has no holes, adding this attribute could only
> decrease efficiency.
> Note that HashEntry structure is used for a large (8MB) array so
> this won't affect much possible container size.
> 
> Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> ---
>  server/glz-encoder-priv.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/server/glz-encoder-priv.h b/server/glz-encoder-priv.h
> index 08dc007ce..7757f232c 100644
> --- a/server/glz-encoder-priv.h
> +++ b/server/glz-encoder-priv.h
> @@ -76,7 +76,7 @@ struct WindowImageSegment {
>  };
>  
>  
> -struct  __attribute__ ((__packed__)) HashEntry {
> +struct HashEntry {
>      uint32_t image_seg_idx;
>      uint32_t ref_pix_idx;
>  };
> --
> 2.20.1
> 
>

> 
> Hi,
> 
> On Mon, Jul 22, 2019 at 12:08:39PM +0100, Frediano Ziglio wrote:
> > The structure has no holes, adding this attribute could only
> > decrease efficiency.
> 
> Why does it decrease efficiency?
> 

If the giant array that contains these structure get unaligned as the
previous fields are not 4/8 bytes aligned the addresses won't be aligned.
And unaligned accesses are less efficient (even more for a hash table
as the read/write are not sequential).
Actually being a cache maybe would be worth forcing 8 bytes of alignment
instead of 4, today many architecture have 64 bit buses (with some
GPU having 128 or even 256 bits buses!).

> > Note that HashEntry structure is used for a large (8MB) array so
> > this won't affect much possible container size.
> > 
> > Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
> > ---
> >  server/glz-encoder-priv.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/server/glz-encoder-priv.h b/server/glz-encoder-priv.h
> > index 08dc007ce..7757f232c 100644
> > --- a/server/glz-encoder-priv.h
> > +++ b/server/glz-encoder-priv.h
> > @@ -76,7 +76,7 @@ struct WindowImageSegment {
> >  };
> >  
> >  
> > -struct  __attribute__ ((__packed__)) HashEntry {
> > +struct HashEntry {
> >      uint32_t image_seg_idx;
> >      uint32_t ref_pix_idx;
> >  };
> > --
> > 2.20.1
> > 
> > _______________________________________________
> > Spice-devel mailing list
> > Spice-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/spice-devel
>