Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deal with Printer::scratch (#6469) #6472

Merged
merged 3 commits into from
Dec 8, 2021
Merged

Conversation

steven-johnson
Copy link
Contributor

Instead of trying to optimize every Printer instance to use stack (and failing), move the StackPrinter concept into printer.h directly and require opt-in at the point of compilation to use stack instead of malloc.

This PR also does a few other drive-by cleanups:

  • Ensures that all Printer ctors are explicit
  • Makes some template aliases to make using (e.g.) ErrorPrinter with a custom buffer size slightly cleaner syntax
  • Have tracing use the .str() method, which already deals with MSAN internally
  • Make all the Printer data members private
  • Fix some evil code in opencl.cpp that previously used the now-private data members

Instead of trying to optimize every Printer instance to use stack (and failing), move the StackPrinter concept into printer.h directly and require opt-in at the point of compilation to use stack instead of malloc.

This PR also does a few other drive-by cleanups:
- Ensures that all Printer ctors are explicit
- Makes some template aliases to make using (e.g.) ErrorPrinter with a custom buffer size slightly cleaner syntax
- Have tracing use the `.str()` method, which already deals with MSAN internally
- Make all the Printer data members private
- Fix some evil  code in opencl.cpp that previously used the now-private data members
steven-johnson added a commit that referenced this pull request Dec 6, 2021
This builds on top of #6472 to de-inline as much of Printer as possible, moving things into a new 'printer' runtime module using a PrinterBase class.

This is, admittedly, a pretty small improvement: comparing before-and-after on OSX for target=host shows only a ~4k reduction in object size (115k -> 111k for `runtime.o`) but adding targets with more verbose error reporting and such increases the benefit (eg host-opencl gives a 179k -> 164k reduction for runtime.o).

Since ~all of the usages of Printer in runtime are for error handling, debugging, profiling, or tracing, any possible reduction in performance seems unlikely to be significant.
Copy link
Contributor

@slomp slomp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@steven-johnson steven-johnson merged commit 59118de into master Dec 8, 2021
@steven-johnson steven-johnson deleted the srj/stack-printer branch December 8, 2021 22:12
steven-johnson added a commit that referenced this pull request Dec 15, 2021
This builds on top of #6472 to de-inline as much of Printer as possible, moving things into a new 'printer' runtime module using a PrinterBase class.

This is, admittedly, a pretty small improvement: comparing before-and-after on OSX for target=host shows only a ~4k reduction in object size (115k -> 111k for `runtime.o`) but adding targets with more verbose error reporting and such increases the benefit (eg host-opencl gives a 179k -> 164k reduction for runtime.o).

Since ~all of the usages of Printer in runtime are for error handling, debugging, profiling, or tracing, any possible reduction in performance seems unlikely to be significant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants