Skip to content

Conversation

@treeowl
Copy link
Contributor

@treeowl treeowl commented Sep 21, 2018

No description provided.


-- | Basic type for a socket.
data Socket = Socket (IORef CInt) CInt {- for Show -}
data Socket = Socket !(IORef CInt) !CInt {- for Show -}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah... actually, it should probably just be an IORef Validity! That removes the redundancy and also the CInt box in the IORef.

@kazu-yamamoto
Copy link
Collaborator

I'm traveling. I will look your issues in the next week.

@eborden
Copy link
Collaborator

eborden commented Sep 21, 2018

@treeowl Thanks for the PR. Could you please provide a description of this work, as well as a reason for its inclusion?

@eborden eborden mentioned this pull request Sep 21, 2018
@treeowl
Copy link
Contributor Author

treeowl commented Sep 21, 2018

@eborden, it gets rid of some indirections and unnecessary boxes. What in particular do you find unclear?

@eborden
Copy link
Collaborator

eborden commented Sep 21, 2018

@treeowl This isn't necessarily about being unclear. This PR introduces a fair amount of complexity by pulling in prim-ops. Increase complexity brings with it a maintenance burden. I'm curious if the performance benefit here pays for the complexity cost.

@treeowl
Copy link
Contributor Author

treeowl commented Sep 21, 2018

I can't say for sure. Using a custom deal for the Weak saves two words per socket. Each small field that's made strict saves a couple words and indirections; moreover, it seems semantically right.

@eborden
Copy link
Collaborator

eborden commented Sep 21, 2018

@treeowl I would easily approve the BangPatterns in this PR, the prim-ops are the more controversial item. Could you split these into two PRs?

-- value. This is similar to 'Data.IORef.mkWeakIORef', but we use it
-- to avoid keeping the useless 'IORef' wrapper alive.
mkWeakFromIORef :: IORef a -> b -> IO () -> IO (Weak b)
mkWeakFromIORef (IORef (STRef r##)) b (IO finalizer) = IO $ \s ->
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd also love to see this function move to its own internal module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. I'll move it.

@treeowl
Copy link
Contributor Author

treeowl commented Sep 21, 2018

I suppose. The thing is that mkWeakIORef should really be the function I defined; there's nothing weird about it....

@eborden eborden added the WIP label Sep 21, 2018
@Mistuke
Copy link
Collaborator

Mistuke commented Sep 22, 2018

I suppose. The thing is that mkWeakIORef should really be the function I defined; there's nothing weird about it....

I think I agree here... However I also think it won't matter much here.. But I have no objections.

@eborden
Copy link
Collaborator

eborden commented Sep 22, 2018

Is mkWeakFromIORef better served as a proposal to the CLC for inclusion in base?

@Mistuke
Copy link
Collaborator

Mistuke commented Sep 22, 2018

I don't think it's big enough to require CLC approval, just a patch to base would be enough imho. That said, even if it makes it into base, it won't be usable here for a while.. unless you check for base versions.

@kazu-yamamoto
Copy link
Collaborator

To make a step forward, may I copy BangPatterns stuff to master?

@eborden
Copy link
Collaborator

eborden commented Oct 10, 2018

👍 That sounds like a good step forward.

kazu-yamamoto added a commit to kazu-yamamoto/network that referenced this pull request Oct 11, 2018
@kazu-yamamoto
Copy link
Collaborator

Done. I would close this issue.

@treeowl If you really want to bring prim-ops stuff to network, please send us another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants