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

Add cleanup to folds #904

Closed
wants to merge 2 commits into from
Closed

Add cleanup to folds #904

wants to merge 2 commits into from

Conversation

adithyaov
Copy link
Member

@adithyaov adithyaov commented Feb 3, 2021

  • Check regressions
  • Fix compile errors in tests and benchmarks
  • Fix formatting (<= 80 lines) (Only a few outliers)
  • Add cleanup to classifySessionsBy

@adithyaov
Copy link
Member Author

Regression report attached
report.txt

@@ -378,6 +378,13 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) =
FL.Partial rr -> extract1 rr
FL.Done () -> return ()

clean (Tuple' Nothing r1) = clean1 r1
clean (Tuple' (Just buf) r1) = do
Copy link
Member Author

Choose a reason for hiding this comment

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

Just clean up directly here. Don't perform unnecessary actions.

@@ -156,6 +156,13 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) =
FL.Partial rr -> extract1 rr
FL.Done _ -> return ()

clean (Tuple' Nothing r1) = clean1 r1
clean (Tuple' (Just buf) r1) = do
r <- step1 r1 buf
Copy link
Member Author

Choose a reason for hiding this comment

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

Unnecessary action?

-- TODO
-- 1. Rename mkFold-ish combinators
-- 1. Add cleanup based smart constructors

Copy link
Member Author

Choose a reason for hiding this comment

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

Need suggestions on naming.

@@ -434,10 +465,14 @@ toList = mkAccum (\f x -> f . (x :)) id ($ [])
-- Instances
------------------------------------------------------------------------------

-- XXX The reason I used "Monad m" is because it is used by "cleanup". I could
-- have used applicative for nocleanup but I don't think it really matters.

Copy link
Member Author

Choose a reason for hiding this comment

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

Remove this line after review.

-- TODO Parsers will also have a cleanup action. The correct behaviour now is
-- for the parsers to clean up the Fold resources while extracting. This is
-- omitted now as parser will have a seperate cleanup later.

Copy link
Member Author

Choose a reason for hiding this comment

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

Remove after review.

Copy link
Member Author

Choose a reason for hiding this comment

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

We could clean up when extracting.

@@ -1751,6 +1751,7 @@ data SessionState t m k a b = SessionState
, sessionOutputStream :: t (m :: Type -> Type) (k, b) -- ^ Completed sessions
}

-- XXX Need to check where to cleanup
Copy link
Member Author

Choose a reason for hiding this comment

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

This is still incomplete. I Will get back to this or the reviewer can help me out if the info is known.

Comment on lines -316 to +318
extract () = liftIO $ sendStop svar winfo
extract () = return ()

cleanup () = liftIO $ sendStop svar winfo
Copy link
Member Author

Choose a reason for hiding this comment

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

See the effects

Comment on lines +345 to +348
extract _ = return ()

cleanup True = liftIO $ sendStop svar winfo
cleanup False = return ()
Copy link
Member Author

Choose a reason for hiding this comment

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

See the effects of this.

@@ -352,21 +352,27 @@ writeChunks
=> (Word8, Word8, Word8, Word8)
-> PortNumber
-> Fold m (Array Word8) ()
writeChunks addr port = Fold step initial extract
writeChunks addr port = Fold step initial extract cleanup
Copy link
Member Author

Choose a reason for hiding this comment

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

Cleanup internal fold in initial on exception?

@adithyaov adithyaov marked this pull request as ready for review February 4, 2021 10:41
@adithyaov adithyaov linked an issue Feb 10, 2021 that may be closed by this pull request
@@ -615,14 +615,22 @@ lpackArraysChunksOf n (Fold step1 initial1 extract1) =
FL.Partial rr -> extract1 rr
FL.Done _ -> return ()

clean (Tuple3' Nothing' _ r1) = clean1 r1
clean (Tuple3' (Just' buf) boff r1) = do
Copy link
Member Author

Choose a reason for hiding this comment

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

unnecessary action?

@adithyaov adithyaov added this to the 0.8.2 milestone Aug 27, 2021
@harendra-kumar harendra-kumar modified the milestones: 0.8.2, 0.9.0 Mar 4, 2022
@harendra-kumar harendra-kumar marked this pull request as draft June 21, 2023 12:49
@harendra-kumar harendra-kumar modified the milestones: 0.9.0, 0.10.0 Jul 13, 2023
@harendra-kumar
Copy link
Member

Fixed by #2427

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 a done action in the Fold type
2 participants