On 13/06/17 01:31 AM, Marek Olšák wrote:
> From: Marek Olšák <marek.ol...@amd.com>
> 
> ---
>  src/gallium/auxiliary/util/u_threaded_context.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/src/gallium/auxiliary/util/u_threaded_context.c 
> b/src/gallium/auxiliary/util/u_threaded_context.c
> index 3038fc6..a97f016 100644
> --- a/src/gallium/auxiliary/util/u_threaded_context.c
> +++ b/src/gallium/auxiliary/util/u_threaded_context.c
> @@ -195,22 +195,27 @@ _tc_sync(struct threaded_context *tc, const char *info, 
> const char *func)
>  
>     tc_debug_check(tc);
>  }
>  
>  #define tc_sync(tc) _tc_sync(tc, "", __func__)
>  #define tc_sync_msg(tc, info) _tc_sync(tc, info, __func__)
>  
>  static void
>  tc_set_resource_reference(struct pipe_resource **dst, struct pipe_resource 
> *src)
>  {
> -   *dst = NULL;
> -   pipe_resource_reference(dst, src);
> +   /* Unexpectedly, pipe_resource_reference is a bottleneck here, taking 3.7%
> +    * of CPU time in a state-heavy microbenchmark. The problem here is that
> +    * pipe_resource_reference isn't inlined here.
> +    */
> +   *dst = src;
> +   if (src)
> +      p_atomic_inc(&src->reference.count);
>  }

That's pretty ugly. Does the attached patch help as well? It allows
pipe_resource_reference to be inlined again, and has a pretty dramatic
effect on the size of the generated code for me:

   text    data     bss     dec     hex filename
  42586     512       0   43098    a85a u_threaded_context.o
  35282     512       0   35794    8bd2 u_threaded_context.o.patched

   text    data     bss     dec     hex filename
10434626         271176 2062272 12768074         c2d34a /tmp/radeonsi_dri.so
10001218         271176 2062272 12334666         bc364a 
/tmp/radeonsi_dri.so.patched


It might also help for other pipe_resource_reference callers.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
From b27caea273ddce499eadded47cf0ac4e2bbeefd8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <michel.daen...@amd.com>
Date: Tue, 13 Jun 2017 12:02:59 +0900
Subject: [PATCH] gallium/util: Allow pipe_resource_reference to be inlined
 again
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Michel Dänzer <michel.daen...@amd.com>
---
 src/gallium/auxiliary/util/u_inlines.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index 6a3d5043cf..753a7bc379 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -131,13 +131,24 @@ pipe_surface_release(struct pipe_context *pipe, struct pipe_surface **ptr)
 
 
 static inline void
+pipe_resource_base_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
+{
+   struct pipe_resource *old_tex = *ptr;
+
+   if (pipe_reference_described(&(*ptr)->reference, &tex->reference, 
+                                (debug_reference_descriptor)debug_describe_resource))
+      old_tex->screen->resource_destroy(old_tex->screen, old_tex);
+   *ptr = tex;
+}
+
+static inline void
 pipe_resource_reference(struct pipe_resource **ptr, struct pipe_resource *tex)
 {
    struct pipe_resource *old_tex = *ptr;
 
    if (pipe_reference_described(&(*ptr)->reference, &tex->reference, 
                                 (debug_reference_descriptor)debug_describe_resource)) {
-      pipe_resource_reference(&old_tex->next, NULL);
+      pipe_resource_base_reference(&old_tex->next, NULL);
       old_tex->screen->resource_destroy(old_tex->screen, old_tex);
    }
    *ptr = tex;
-- 
2.11.0

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to