Module: Mesa
Branch: main
Commit: 05a4d3f3805181747bd87e7e87a82160cdcccd98
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=05a4d3f3805181747bd87e7e87a82160cdcccd98

Author: Chia-I Wu <[email protected]>
Date:   Mon Oct 31 14:27:08 2022 -0700

freedreno/pps: loop countables by references

Mainly to get rid of alloc/free in collect_countables.  Sampling at 1ms,
perf becomes

   - 22.75% pps::FreedrenoDriver::collect_countables
           22.59% pps::FreedrenoDriver::Countable::collect

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19427>

---

 src/freedreno/ds/fd_pps_driver.cc | 12 ++++++------
 src/freedreno/ds/fd_pps_driver.h  |  6 +++---
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/src/freedreno/ds/fd_pps_driver.cc 
b/src/freedreno/ds/fd_pps_driver.cc
index 23f1bded1fa..a75f4435d99 100644
--- a/src/freedreno/ds/fd_pps_driver.cc
+++ b/src/freedreno/ds/fd_pps_driver.cc
@@ -403,7 +403,7 @@ FreedrenoDriver::configure_counters(bool reset, bool wait)
       (enum fd_ringbuffer_flags)(FD_RINGBUFFER_PRIMARY | 
FD_RINGBUFFER_GROWABLE);
    struct fd_ringbuffer *ring = fd_submit_new_ringbuffer(submit, 0x1000, 
flags);
 
-   for (auto countable : countables)
+   for (const auto &countable : countables)
       countable.configure(ring, reset);
 
    struct fd_submit_fence fence = {};
@@ -428,7 +428,7 @@ FreedrenoDriver::collect_countables()
 {
    last_dump_ts = perfetto::base::GetBootTimeNs().count();
 
-   for (auto countable : countables)
+   for (const auto &countable : countables)
       countable.collect();
 }
 
@@ -476,7 +476,7 @@ FreedrenoDriver::init_perfcnt()
 
    state.resize(next_countable_id);
 
-   for (auto countable : countables)
+   for (const auto &countable : countables)
       countable.resolve();
 
    info = fd_dev_info(dev_id);
@@ -593,7 +593,7 @@ FreedrenoDriver::Countable::Countable(FreedrenoDriver *d, 
std::string name)
 
 /* Emit register writes on ring to configure counter/countable muxing: */
 void
-FreedrenoDriver::Countable::configure(struct fd_ringbuffer *ring, bool reset)
+FreedrenoDriver::Countable::configure(struct fd_ringbuffer *ring, bool reset) 
const
 {
    const struct fd_perfcntr_countable *countable = d->state[id].countable;
    const struct fd_perfcntr_counter   *counter   = d->state[id].counter;
@@ -624,7 +624,7 @@ FreedrenoDriver::Countable::configure(struct fd_ringbuffer 
*ring, bool reset)
 
 /* Collect current counter value and calculate delta since last sample: */
 void
-FreedrenoDriver::Countable::collect()
+FreedrenoDriver::Countable::collect() const
 {
    const struct fd_perfcntr_counter *counter = d->state[id].counter;
 
@@ -639,7 +639,7 @@ FreedrenoDriver::Countable::collect()
 
 /* Resolve the countable and assign next counter from it's group: */
 void
-FreedrenoDriver::Countable::resolve()
+FreedrenoDriver::Countable::resolve() const
 {
    for (unsigned i = 0; i < d->num_perfcntrs; i++) {
       const struct fd_perfcntr_group *g = &d->perfcntrs[i];
diff --git a/src/freedreno/ds/fd_pps_driver.h b/src/freedreno/ds/fd_pps_driver.h
index 29f738b313e..0da9cfcebfa 100644
--- a/src/freedreno/ds/fd_pps_driver.h
+++ b/src/freedreno/ds/fd_pps_driver.h
@@ -103,9 +103,9 @@ private:
 
       operator int64_t() const { return get_value(); };
 
-      void configure(struct fd_ringbuffer *ring, bool reset);
-      void collect();
-      void resolve();
+      void configure(struct fd_ringbuffer *ring, bool reset) const;
+      void collect() const;
+      void resolve() const;
 
    private:
 

Reply via email to