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

[ADDED] Support for route permissions config reload #753

Merged
merged 4 commits into from
Sep 27, 2018

Conversation

kozlovic
Copy link
Member

Signed-off-by: Ivan Kozlovic [email protected]

@coveralls
Copy link

coveralls commented Sep 19, 2018

Coverage Status

Coverage increased (+0.3%) to 92.56% when pulling 4cd3453 on route_perms_reload into a065d13 on master.

Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

Small comments but LGTM.

server/reload.go Outdated

// Go through all local subscriptions
for _, sub := range localSubs {
sub.client.mu.Lock()
Copy link
Member

Choose a reason for hiding this comment

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

Why the lock here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I used to have a flag in the sub to know if we already sent a SUB to routes, to know if we should or not send it again. But that wasn't too good, but explains why I had the lock here. Will remove (although we access sub.subject, but this is immutable).

server/reload.go Outdated
route.sendInfo(infoJSON)
// Now send SUB and UNSUB protocols as needed.
for _, sub := range subsNeedSUB {
route.queueOutbound([]byte(fmt.Sprintf(subProto, sub.subject, sub.queue, routeSid(sub))))
Copy link
Member

Choose a reason for hiding this comment

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

These fmt can be expensive if we have alot of sub/unsubs. Might be good to do some high sub benchmarking to see if we want to change out how these loops work.

Copy link
Member Author

Choose a reason for hiding this comment

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

What would be the alternative, though?

Copy link
Member

Choose a reason for hiding this comment

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

Format by hand, avoid fmt.Sprintf, use a large staged buffer or something and only send occasionally to the socket etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought queueOutbound would do that (not sending right away), hence presence of signal. But passed buffer may not be copied, so we can't "reuse" a stack buffer to build the protocol, right?

Copy link
Member

Choose a reason for hiding this comment

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

It will reference (with sketchy ownership) if data passed in is larger than maxBufSize. Otherwise it copies it. We should just measure it and if there is a concern put a TODO comment in the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do, but understand that this is no different than route sending local subs interest on route connect.

Copy link
Member

Choose a reason for hiding this comment

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

Need to optimize that one too IMO, and I will most likely during rewrite.. :)

- Removed un-needed lock/unlock
- Buffer SUBs/UNSUBs protocols and ensure flushing when buffer
  gets to a certain size (otherwise route would get disconnected
  with high number of subscriptions)

Signed-off-by: Ivan Kozlovic <[email protected]>
- Use stack buffers
- Ensure that buffer size is no greater than 90% of max_pending
- Added test with low max_pending

Signed-off-by: Ivan Kozlovic <[email protected]>
Copy link
Member

@derekcollison derekcollison left a comment

Choose a reason for hiding this comment

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

Minor comment but LGTM

server/route.go Outdated
_buf [staticBufSize]byte // array on stack
buf = _buf[:0] // our buffer will initially point to the stack buffer
mbs = staticBufSize // max size of the buffer
mpMax = int(c.out.mp * 90 / 100) // 90% of max_pending
Copy link
Member

Choose a reason for hiding this comment

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

I would do 1/2 here.

@kozlovic
Copy link
Member Author

@derekcollison Made the change. Let me know if ok to merge as-is or want me to squash.

@derekcollison
Copy link
Member

Merge as is I think.

@kozlovic kozlovic merged commit d5ceade into master Sep 27, 2018
@kozlovic kozlovic deleted the route_perms_reload branch September 27, 2018 16:08
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.

3 participants