Skip to content

A little unboxing and strictifying - #351

Closed
treeowl wants to merge 1 commit into
haskell:masterfrom
treeowl:unbox
Closed

treeowl wants to merge 1 commit into
haskell:masterfrom
treeowl:unbox

Conversation

@treeowl

@treeowl treeowl commented Sep 21, 2018

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread Network/Socket/Types.hsc

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

Copy link
Copy Markdown
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
Copy Markdown
Collaborator

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

@eborden

eborden commented Sep 21, 2018

Copy link
Copy Markdown
Collaborator

@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

treeowl commented Sep 21, 2018

Copy link
Copy Markdown
Contributor Author

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

@eborden

eborden commented Sep 21, 2018

Copy link
Copy Markdown
Collaborator

@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

treeowl commented Sep 21, 2018

Copy link
Copy Markdown
Contributor Author

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

eborden commented Sep 21, 2018

Copy link
Copy Markdown
Collaborator

@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?

Comment thread Network/Socket/Types.hsc
-- 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
Copy Markdown
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
Copy Markdown
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

treeowl commented Sep 21, 2018

Copy link
Copy Markdown
Contributor Author

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

Mistuke commented Sep 22, 2018

Copy link
Copy Markdown
Collaborator

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

eborden commented Sep 22, 2018

Copy link
Copy Markdown
Collaborator

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

@Mistuke

Mistuke commented Sep 22, 2018

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Collaborator

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

@eborden

eborden commented Oct 10, 2018

Copy link
Copy Markdown
Collaborator

👍 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
Copy Markdown
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