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

Minor cleanup in PagingSelfAwareStructuredLogger #849

Merged

Conversation

morgen-peschke
Copy link
Contributor

Materialize the paged message before interacting with it.

Previously the message would be materialized multiple times:

  • 1 : in call to addMsgCtx
  • 3 or 1 + 3p : in call to pagedLogging
    • Lower Bound (single page): 3
      • 1 : calculate the number of pages
      • 1 : in call to addPageCtx (calculate the page length)
      • 1 : in call to logOpWithCtx
    • Upper Bound (p pages): 1 + 3p
      • 1 : calculate the number of pages
      • 1p : msg is materialized every time a page is sliced from the message
      • 1p : in call to addPageCtx (calculate the page length)
      • 1p : in call to logOpWithCtx

Materializing early gives these improvements:

  • Single page: from 4 times to 1 time
  • Multiple pages: from 2 + 3p times to 1 time

Removes some by-name parameters that were always called with materialized values.

Simplifies unneeded calls to Show on Int or String values, which doesn't have any particular benefit, particularly if it's inside of a string interpolation anyway.

Calling `Show` on an `Int` or `String` doesn't have any particular benefit, particularly if it's inside of a string interpolation anyway
Previously the message would be materialized multiple times:
- `1` time in `addMsgCtx`
- `3` or `1 + 3p` times in `pagedLogging`
  - Lower Bound (single page): `3` times
    - `1` time to calculate the number of pages
    - `1` time in `addPageCtx` to calculate the page length
    - `1` time when calling `logOpWithCtx`
  - Upper Bound (`p` pages): `1 + 3p`
    - `1` time to calculate the number of pages
    - `1` time per page to split out each page
    - `1` time per page in `addPageCtx` to calculate the page length
    - `1` time per page when calling `logOpWithCtx`

Materializing early gives these improvements:
- Single page: from `4` times to `1` time
- Multiple pages: from `2 + 3p` times to `1` time

Also removes some by-name parameters that were always called with
materialized values.
@rossabaker rossabaker merged commit 8b80d47 into typelevel:main Jun 17, 2024
14 checks passed
@morgen-peschke morgen-peschke deleted the minor-paging-logger-improvements branch June 17, 2024 21:23
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