Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
| 3 | * contributor license agreements. See the NOTICE file distributed with |
| 4 | * this work for additional information regarding copyright ownership. |
| 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 6 | * (the "License"); you may not use this file except in compliance with |
| 7 | * the License. You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
Pierre De Rop | 7935b80 | 2015-05-20 18:21:57 +0000 | [diff] [blame] | 18 | Stress test for Dependency Manager |
| 19 | ================================== |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 20 | |
Pierre De Rop | 7935b80 | 2015-05-20 18:21:57 +0000 | [diff] [blame] | 21 | This module provides a little framework used to perform some stress tests on Dependency Manager. |
| 22 | (but other DI frameworks can easily be integrated). |
| 23 | |
| 24 | What is doing this test ? |
| 25 | ========================= |
| 26 | |
| 27 | This loader measures the time nedded to create a graph of service components that have dependencies |
| 28 | between each other. For sake of simplicity, a simple scenario domain is used (actually, this example |
| 29 | domain has been inspired from the "Java8 Lambdas" book, O'reilly) and the following services are used: |
| 30 | |
| 31 | - Artist service: An Artist is an individual or group of musicians, who creates some "Albums". One |
| 32 | Artist service depends on several Album services. |
| 33 | |
| 34 | - Album service: is a single release of musics, comprising several music Tracks. One Album depends |
| 35 | on several Track services. |
| 36 | |
| 37 | - Track service: A piece of music. |
| 38 | |
| 39 | The scenario consists in starting/stopping many times a bundle that will synchronously create the |
| 40 | graph of Artist/Album/Track components (630 by default). A scenario controller monitors the number |
| 41 | of created components and when the number of expected components are created, then the controller |
| 42 | stops the bundle, which will then unregister all components. Finally, when the controller detects |
| 43 | that all components are unregistered, the elapsed time is recorded in a list of time duration (in |
| 44 | nano seconds). |
| 45 | |
| 46 | The same is done by another bundle that does exactly the same, but using concurrent component |
| 47 | registration. |
| 48 | |
| 49 | At the end of the test (that is, when the bundle that creates the components has been |
| 50 | started/stopped many times), then the list of all time durations (start/stop) is sorted: the first |
| 51 | element of the list corresponds to the shortest elapsed time used by the bundle to create and destroy the |
| 52 | components; and the last element in the list corresponds to the slowest elapsed time. The |
| 53 | middle in the duration time list is the average. We display the first entry (fastest), the entry at 1/4 |
| 54 | of the list, the middle of the list, the entry at 3/4 of the list, and the last entry (slowest time). |
| 55 | We don't do an average, because usually, when running benchmark, some measurements don't reflect reality, |
| 56 | especially, when there is a full GC or when the JVM is warming up. (we actually do the same as in Java |
| 57 | Chronicle: https://github.com/peter-lawrey/Java-Chronicle). |
| 58 | |
| 59 | Bundle descriptions: |
| 60 | =================== |
| 61 | |
| 62 | - org.apache.felix.dm.benchmark.dependencymanager: a test bundle that creates the components synchronously |
| 63 | when the bundle is started. And when it is stopped, then the components are unregistered. |
| 64 | |
| 65 | - org.apache.felix.dm.benchmark.dependencymanager.parallel: same as before, but the components are |
| 66 | created concurrently. |
| 67 | |
| 68 | - org.apache.felix.dm.benchmark.scenario: this bundle contains the component classes that are |
| 69 | part of the scenario: we have an Artist service that depends on some Albums services, each Album |
| 70 | also depends on some music Track services. The components are bound using a special "id" service |
| 71 | property. |
| 72 | |
| 73 | - org.apache.felix.dm.benchmark.scenario.impl: the simple Artist/Albums/Track implementations. |
| 74 | |
| 75 | - org.apache.felix.dm.benchmark.controller: provides a ScenarioController service that is |
| 76 | injected in all Artist/Album/Track components. When an Artist, an Album, or a Track component is |
| 77 | started, it notifies the ScenerioController. Then when the controller detects that all components |
| 78 | are properly created, it then stops the bundle, which in turns unregisters all components. |
| 79 | |
| 80 | - org.apache.felix.dm.benchmark.controller.impl: this is the ScenarioController implementation. |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 81 | |
| 82 | How to launch the stress test under bndtools: |
| 83 | ============================================ |
| 84 | |
Pierre De Rop | 7935b80 | 2015-05-20 18:21:57 +0000 | [diff] [blame] | 85 | The stress test performs two kinds of tests on DM and parallel DM: |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 86 | |
Pierre De Rop | 7935b80 | 2015-05-20 18:21:57 +0000 | [diff] [blame] | 87 | -noindex.bndrun: the tests is performed without using optimized DM filter indices. |
| 88 | -index.bndrun: the test is performed with the DM filter indices. |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 89 | |
| 90 | To launch the stress test under BndTools, click on the noindex.bndrun file of the |
| 91 | "org.apache.felix.dm.benchmark" project, then click on "Run", then in "Run OSGi". |
| 92 | |
| 93 | You should see something like that in the eclipse console: |
| 94 | |
| 95 | >> -------------------------------------------------------------------------------------------------------------- |
| 96 | g! Starting benchmarks (each tested bundle will add/remove 630 components during bundle activation). |
| 97 | |
| 98 | [Starting benchmarks with no processing done in components start methods] |
| 99 | |
| 100 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager .................... |
| 101 | -> results in nanos: [189,130,687 | 205,730,144 | 312,092,102 | 357,470,857 | 871,419,487] |
| 102 | |
| 103 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager.parallel .................... |
| 104 | -> results in nanos: [85,158,366 | 103,439,337 | 122,633,515 | 157,082,407 | 284,332,202] |
| 105 | |
| 106 | [Starting benchmarks with processing done in components start methods] |
| 107 | |
| 108 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager ..... |
| 109 | -> results in nanos: [2,748,431,149 | 2,750,475,610 | 2,756,254,193 | 2,772,447,115 | 2,774,345,245] |
| 110 | |
| 111 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager.parallel ..... |
| 112 | -> results in nanos: [687,259,058 | 696,725,568 | 700,220,615 | 704,310,739 | 740,325,481] |
| 113 | ----------------------------------------------------------------------------------------------------------------- |
| 114 | |
Pierre De Rop | 7935b80 | 2015-05-20 18:21:57 +0000 | [diff] [blame] | 115 | You can also run the same test using optimized DM filter indices. |
| 116 | To do so, run "index.bndrun". But using DM filter indices has a CPU cost and are useful if you have many service dependencies. |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 117 | To test filter indices, first increase the number of components created/removed during bundle |
Pierre De Rop | defc0a3 | 2015-03-19 06:13:48 +0000 | [diff] [blame] | 118 | startup. To do so, edit the Artist.java and change the "Artists" from 30 to 300. |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 119 | |
| 120 | You should then observe some significant performance improvements: |
| 121 | |
| 122 | for example, with Artist.ARTISTS=300, you should observe the following: |
| 123 | |
| 124 | noindex.bndrun (no filter indices used): |
| 125 | |
| 126 | >> -------------------------------------------------------------------------------------------------------------- |
| 127 | g! Starting benchmarks (each tested bundle will add/remove 6300 components during bundle activation). |
| 128 | |
| 129 | [Starting benchmarks with no processing done in components start methods] |
| 130 | |
| 131 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager ..... |
| 132 | -> results in nanos: [17,436,869,644 | 17,525,534,346 | 18,080,624,001 | 18,246,597,908 | 20,715,696,669] |
| 133 | |
| 134 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager.parallel ..... |
| 135 | -> results in nanos: [9,660,520,501 | 9,810,057,488 | 9,870,295,166 | 10,014,334,906 | 10,628,193,815] |
| 136 | |
| 137 | [Starting benchmarks with processing done in components start methods] |
| 138 | |
| 139 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager ..... |
| 140 | -> results in nanos: [42,700,651,438 | 43,207,156,615 | 43,653,372,523 | 43,869,438,994 | 44,715,701,457] |
| 141 | |
| 142 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager.parallel ..... |
| 143 | -> results in nanos: [15,021,876,153 | 15,091,340,552 | 15,202,305,936 | 15,248,728,826 | 15,398,221,492] |
| 144 | ----------------------------------------------------------------------------------------------------------------- |
| 145 | |
| 146 | and with index.bndrun (using DM filter indices): |
| 147 | |
| 148 | >> -------------------------------------------------------------------------------------------------------------- |
| 149 | g! Starting benchmarks (each tested bundle will add/remove 6300 components during bundle activation). |
| 150 | |
| 151 | [Starting benchmarks with no processing done in components start methods] |
| 152 | |
| 153 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager ..... |
| 154 | -> results in nanos: [3,142,869,517 | 3,564,970,695 | 4,023,603,870 | 6,206,640,362 | 6,918,113,818] |
| 155 | |
| 156 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager.parallel ..... |
| 157 | -> results in nanos: [2,868,554,914 | 2,873,491,201 | 2,897,439,973 | 2,913,317,331 | 3,890,123,728] |
| 158 | |
| 159 | [Starting benchmarks with processing done in components start methods] |
| 160 | |
| 161 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager ..... |
| 162 | -> results in nanos: [28,515,623,505 | 28,558,774,886 | 28,661,315,061 | 28,808,682,302 | 28,915,519,208] |
| 163 | |
| 164 | Benchmarking bundle: org.apache.felix.dependencymanager.benchmark.dependencymanager.parallel ..... |
| 165 | -> results in nanos: [7,702,400,991 | 7,749,145,806 | 7,760,650,323 | 7,832,386,237 | 7,854,739,136] |
| 166 | ----------------------------------------------------------------------------------------------------------------- |
| 167 | |
| 168 | |
| 169 | How to interpret results: |
| 170 | ======================== |
| 171 | |
| 172 | for each tested bundle, the time spent is displayed in nanos. |
| 173 | for example: |
| 174 | |
| 175 | -> results in nanos: [85,158,366 | 103,439,337 | 122,633,515 | 157,082,407 | 284,332,202] |
| 176 | |
Pierre De Rop | 7935b80 | 2015-05-20 18:21:57 +0000 | [diff] [blame] | 177 | Here, the shortest time used to activate and bind the components with each other took around 85,158,366 nanos. |
| 178 | the value in the midle of the list represents the averate time (122,633,515 nanos. |
| 179 | the last entry is the slowest elapsed time (284,332,202). |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 180 | |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 181 | |
Pierre De Rop | 3a00a21 | 2015-03-01 09:27:46 +0000 | [diff] [blame] | 182 | |