alamb opened a new pull request, #27966:
URL: https://github.com/apache/datafusion/pull/27966

   ## Which issue does this PR close?
   
   - None. This is a follow up to [perf(repartition): lazily register send 
metrics](https://github.com/apache/datafusion/pull/27915), from this [review 
comment](https://github.com/apache/datafusion/pull/27915#discussion_r4773913155)
 about avoiding string allocations for integer-valued metric labels.
   
   ## Rationale for this change
   
   Formatting a `Metric` with `Display` built a temporary `Label` for the 
partition number, which allocates a `String` and then an `Arc<str>`, and cloned 
every existing label, only to print them and drop them.
   
   This code only runs when metrics are displayed (for example in `EXPLAIN 
ANALYZE`), not while a query executes, so this is a small cleanup. I have not 
measured any performance difference and do not expect a noticeable one.
   
   ## What changes are included in this PR?
   
   `impl Display for Metric` now writes `partition={n}` and each label directly 
to the formatter instead of building an intermediate iterator of owned `Label`s.
   
   ## What is the testing strategy for this PR?
   
   The output is unchanged and is covered by the existing tests in 
`datafusion/physical-expr-common/src/metrics/mod.rs`:
   
   - `test_display_no_labels_no_partition`
   - `test_display_no_labels_with_partition`
   - `test_display_labels_no_partition`
   - `test_display_labels_and_partition`
   
   ## Are there any user-facing changes?
   
   No. The displayed text is the same and there are no public API changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to