Skip to content

Conversation

@jappeace
Copy link

@jappeace jappeace commented Aug 28, 2024

Fixes #153

This introduces an alternative api which allows the following code to run without memory build up.

logLoop :: KatipContextT IO ()
logLoop = do
  katipSetContext "xx" someContext $ do
      $(logTM) InfoS "Hello Katip"
      logLoop

new katipSetContext:

image

compared to katipAddContext:

image

NB, see my reproducer repo for the code that generated these graphs:
https://github.com/jappeace/katip

My initial attempt failed because the map needed to have a strict field (I'm uncertain why).

@ozataman
Copy link
Member

Taking a stab at this without running the code (sorry not able to ATM). The way you're looping, aren't you just repeatedly calling katipAddContext in each loop? So you keep adding/setting context in deeper calls. I assume that you're accumulating large thunks in the data type underlying the sl construction. Instead, you should be a setting the context a single time, then loop the inner part of the code.

@jappeace

This comment was marked as outdated.

@jappeace jappeace marked this pull request as ready for review September 1, 2024 17:46
@jappeace
Copy link
Author

jappeace commented Sep 5, 2024

btw those recent changes made this work ^ @MichaelXavier @ozataman

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.

Add katipSetContext that doesn't leak under recursion

2 participants