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

Remove Object Pool #1969

Closed

Conversation

benjchristensen
Copy link
Member

PR #1944 rebased onto 1.x.

This removes the use of object pooling as per discussion in #1908 to achieve correctness. Performance stats will follow in comments.

@benjchristensen
Copy link
Member Author

Here is the performance hit on one of the scenarios that benefits the most from object pooling:

1.x

Benchmark                                    (size)   Mode   Samples        Score  Score error    Units
r.o.OperatorMergePerf.merge1SyncStreamOfN         1  thrpt         5  4493516.238   855611.781    ops/s
r.o.OperatorMergePerf.merge1SyncStreamOfN      1000  thrpt         5    39848.200     3011.983    ops/s
r.o.OperatorMergePerf.merge1SyncStreamOfN   1000000  thrpt         5       38.017        2.865    ops/s


No Object Pool

Benchmark                                    (size)   Mode   Samples        Score  Score error    Units
r.o.OperatorMergePerf.merge1SyncStreamOfN         1  thrpt         5  4809388.856   164553.287    ops/s
r.o.OperatorMergePerf.merge1SyncStreamOfN      1000  thrpt         5    41017.885     1385.965    ops/s
r.o.OperatorMergePerf.merge1SyncStreamOfN   1000000  thrpt         5       39.981        2.307    ops/s

The following Flight Recorder comparisons show the memory and GC impact. This is what concerns me.

With Pooling

pooling-overview-cpu

Without

no-pooling-overview-cpu

With Pooling

pooling-allocations

Without

no-pooling-allocations

With Pooling

pooling-collections

Without

no-pooling-collections

@benjchristensen
Copy link
Member Author

This test is particularly bad: OperatorMergePerf.mergeNAsyncStreamsOfN

With Pooling

screen shot 2014-12-13 at 11 22 24 am

Without

screen shot 2014-12-13 at 11 22 29 am

With Pooling

screen shot 2014-12-13 at 11 22 40 am

Without

screen shot 2014-12-13 at 11 22 45 am

@benjchristensen
Copy link
Member Author

That last set of Flight Recorder tests suggests we can't do this.

@akarnokd
Copy link
Member

I see a few options:

  • longer lasting merge sessions,
  • do backpressure outside the merge, and have the plain no-backpressure merge,
  • use unpadded and smaller queues in merge.

@benjchristensen
Copy link
Member Author

I don't see how any of those are options. Can you please elaborate?

It seems to me the option is either make pooling work or use linked lists.

@akarnokd
Copy link
Member

  • Longer lasting merge sessions: if the merge sources are always the same, create one of it and funnel multiple datastreams through it, each stream having its on custom end marker instead of onCompleted so the merge is not torn down. For example, a single incoming request is always split to 3 concurrent sources which are then merged together and the response is formed after all 3 finished. Instead of merging their plain values, merge a the (request-id, value) then split the resulting streams back to each requester.
  • Change the emission rate in some way. For example, a cache might do its own backpressure directly so no downstream op has to deal with it and queue again.
  • SpscLinkedQueue and SpscArrayQueue use significant padding which adds to the instantiation and in-flight overhead due allocation. Just stripping these of their padding may help. In addition, if the number emitted objects to merge is low compared to the cost of setting up the operators, you could reduce or completely remove the queueing from the merge (a new merge op with queue parameter, or a new merge op without queues and without backpressure).

@benjchristensen benjchristensen deleted the remove-object-pool branch June 11, 2015 21:05
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.

2 participants