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

ARTEMIS-1606 - Change AddressInfo RoutingType Set to use EnumSet #1777

Closed

Conversation

michaelandrepearce
Copy link
Contributor

@michaelandrepearce michaelandrepearce commented Jan 13, 2018

Change all use from Set< RoutingType > to EnumSet<RoutingType>
Deprecating any old exposed interfaces but keeping for back compatibility.
Address info to avoid iterator on getRoutingType hotpath, like wise can be avoided where single RoutingType is passed in.

@michaelandrepearce
Copy link
Contributor Author

@franz1981 ping.

Change all use from Set<RoutingType> to EnumSet<RoutingType>
Deprecating any old exposed interfaces but keeping for back compatibility.
Address info to avoid iterator on getRoutingType hotpath, like wise can be avoided where single RoutingType is passed in.
@franz1981
Copy link
Contributor

@michaelandrepearce
Looking at the changes via Github it seems clean and effective and I admit I'm a fan of using the "right" collection when needed, but I want to use some time tomorrow to check the code locally too and run some CI tests on it: similar to SimpleString changes I prefer to be 100% that isn't impacting negatively with hidden behaviours

@michaelandrepearce
Copy link
Contributor Author

michaelandrepearce commented Jan 17, 2018

@franz1981 did you get a chance to do your local check? you happy for this to merge?

@franz1981
Copy link
Contributor

@michaelandrepearce I'm looking at it locally right now 👍

@cshannon
Copy link
Contributor

This looks good to me too

@jbertram
Copy link
Contributor

Any metrics to quantify the benefit and justify this change?

@michaelandrepearce
Copy link
Contributor Author

michaelandrepearce commented Jan 17, 2018

Sure, using JMH to measure performance of the two AddressInfo Implementations.

Benchmark Mode Cnt Score Error Units
MyBenchmark.testEnumSetAddressInfo thrpt 200 198607467.630 ± 507344.268 ops/s
MyBenchmark.testHashSetAddressInfo thrpt 200 22849376.205 ± 216480.582 ops/s

This is simulating what happens in the hotpath of sending a message in doSend within ServerSessionImpl. Which is creating an AddressInfo and then getRoutingType.

As you note the throughput is an order of magnitude of over 8x.

Also from a java memory footprint this is far better, note the constant size, and that even with one object its more than half the size (nearly almost a third).

AddressInfo using HashSet with one routing type -> 208 bytes
AddressInfo using HashSet with two routing types -> 240 bytes

AddressInfo using EnumSet with one routing type -> 72 bytes
AddressInfo using EnumSet with two routing types -> 72 bytes

@jbertram
Copy link
Contributor

Thanks, @michaelandrepearce. Nice results!

@franz1981
Copy link
Contributor

Very good results! A lil OT but seems that we really start need a JMH folder with all the benchs on Artemis eh? :P

@michaelandrepearce
Copy link
Contributor Author

michaelandrepearce commented Jan 18, 2018

@franz1981 i was waiting on you, to give a thumbs up before i merged, is that a thumbs up?

@jbertram cheers.

@franz1981
Copy link
Contributor

franz1981 commented Jan 18, 2018

@michaelandrepearce I'm running a test before and after, but first can you try add .jvmArgs("-XX:+UseG1GC") and .forks(2) to your benchmark?

@franz1981
Copy link
Contributor

These are the flamegraph of a couple of profiled tests, one on master:
image
Where the violet bars are the AddressInfo::new and the AddressInfo::getRoutingType (+ iterator) while with this PR:
image
There isn't anymore any cost associated with AddressInfo: for me is a thumbs up!
Althouh it seems negligible (at a first look) the impact of this change has changed the garbage produced and the CPU time required to call doSend: indeed the latencies are better too.
Well done 💯

@michaelandrepearce
Copy link
Contributor Author

Great thanks, ill merge then.

@asfgit asfgit closed this in 1d31227 Jan 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants