Restlet 2.1 RC 4をorg.restlet.ext.httpclient
で使用していて、リモートサーバーからデータorg.restlet.ext.jackson
を取得しています。org.restlet.ext.json
ただし、6つのオブジェクトの場合、家のワイヤレスデータ接続では6秒かかります。
ご覧のとおり、GC以外にも、やのようなメッセージがたくさんありStarting the internal [HTTP/1.1] client
ますStopping the internal[HTTP/1.1] client
。これは、非常に時間がかかる大規模なGCに対応しています。
06-01 03:21:46.913: RestletTrip(2653): Querying: [SOMEURL/SOMENUMBER]
06-01 03:21:46.933: I/org.restlet(2653): Starting the internal [HTTP/1.1] client
06-01 03:21:47.053: D/dalvikvm(2653): GC_CONCURRENT freed 708K, 34% free 9214K/13831K, external 576K/1020K, paused 3ms+3ms
06-01 03:21:47.053: I/org.restlet(2653): Stopping the internal[HTTP/1.1] client
06-01 03:21:47.103: D/dalvikvm(2653): GC_FOR_MALLOC freed 4924K, 61% free 5523K/13831K, external 576K/1020K, paused 31ms
06-01 03:21:47.173: D/dalvikvm(2653): GC_CONCURRENT freed 95K, 53% free 6574K/13831K, external 576K/1020K, paused 2ms+3ms
06-01 03:21:47.253: D/dalvikvm(2653): GC_CONCURRENT freed 46K, 43% free 8012K/13831K, external 576K/1020K, paused 2ms+3ms
06-01 03:21:47.734: I/global(2653): Loaded time zone names for en_US in 397ms.
06-01 03:21:48.014: RestletTrip(2653): Querying: [SOMEURL/SOMENUMBER]
06-01 03:21:48.124: D/dalvikvm(2653): GC_CONCURRENT freed 1225K, 38% free 8688K/13831K, external 576K/1020K, paused 3ms+3ms
06-01 03:21:48.124: I/org.restlet(2653): Stopping the internal[HTTP/1.1] client
06-01 03:21:48.134: I/org.restlet(2653): Starting the internal [HTTP/1.1] client
06-01 03:21:48.184: D/dalvikvm(2653): GC_FOR_MALLOC freed 5022K, 62% free 5341K/13831K, external 576K/1020K, paused 31ms
06-01 03:21:48.244: D/dalvikvm(2653): GC_CONCURRENT freed 96K, 55% free 6307K/13831K, external 576K/1020K, paused 2ms+3ms
06-01 03:21:48.314: D/dalvikvm(2653): GC_CONCURRENT freed 44K, 45% free 7663K/13831K, external 576K/1020K, paused 3ms+4ms
06-01 03:21:48.795: I/global(2653): Loaded time zone names for en_US in 405ms.
06-01 03:21:49.015: D/dalvikvm(2653): GC_CONCURRENT freed 695K, 37% free 8736K/13831K, external 576K/1020K, paused 3ms+3ms
06-01 03:21:49.155: RestletTrip(2653): Querying: [SOMEURL/SOMENUMBER]
06-01 03:21:49.165: I/org.restlet(2653): Starting the internal [HTTP/1.1] client
06-01 03:21:49.225: D/dalvikvm(2653): GC_FOR_MALLOC freed 672K, 30% free 9778K/13831K, external 576K/1020K, paused 34ms
06-01 03:21:49.225: I/org.restlet(2653): Stopping the internal[HTTP/1.1] client
06-01 03:21:49.265: D/dalvikvm(2653): GC_FOR_MALLOC freed 4902K, 61% free 5637K/14343K, external 576K/1020K, paused 32ms
06-01 03:21:49.325: D/dalvikvm(2653): GC_CONCURRENT freed 97K, 54% free 6703K/14343K, external 576K/1020K, paused 3ms+4ms
06-01 03:21:49.395: D/dalvikvm(2653): GC_CONCURRENT freed 54K, 44% free 8167K/14343K, external 576K/1020K, paused 3ms+3ms
06-01 03:21:49.876: I/global(2653): Loaded time zone names for en_US in 407ms.
06-01 03:21:50.136: RestletTrip(2653): Querying: [SOMEURL/SOMENUMBER]
06-01 03:21:50.156: I/org.restlet(2653): Starting the internal [HTTP/1.1] client
06-01 03:21:50.236: D/dalvikvm(2653): GC_CONCURRENT freed 1295K, 38% free 8905K/14343K, external 576K/1020K, paused 3ms+4ms
06-01 03:21:50.236: I/org.restlet(2653): Stopping the internal[HTTP/1.1] client
06-01 03:21:50.286: D/dalvikvm(2653): GC_FOR_MALLOC freed 4991K, 61% free 5636K/14343K, external 576K/1020K, paused 32ms
06-01 03:21:50.346: D/dalvikvm(2653): GC_CONCURRENT freed 52K, 53% free 6748K/14343K, external 576K/1020K, paused 2ms+4ms
06-01 03:21:50.386: D/dalvikvm(2653): GC_FOR_MALLOC freed 50K, 43% free 8249K/14343K, external 576K/1020K, paused 30ms
06-01 03:21:50.867: I/global(2653): Loaded time zone names for en_US in 400ms.
06-01 03:21:51.107: RestletTrip(2653): Querying: [SOMEURL/SOMENUMBER]
06-01 03:21:51.127: I/org.restlet(2653): Starting the internal [HTTP/1.1] client
06-01 03:21:51.207: D/dalvikvm(2653): GC_CONCURRENT freed 1290K, 38% free 9006K/14343K, external 576K/1020K, paused 2ms+4ms
06-01 03:21:51.207: I/org.restlet(2653): Stopping the internal[HTTP/1.1] client
06-01 03:21:51.257: D/dalvikvm(2653): GC_FOR_MALLOC freed 4937K, 60% free 5791K/14343K, external 576K/1020K, paused 32ms
06-01 03:21:51.317: D/dalvikvm(2653): GC_CONCURRENT freed 106K, 52% free 6900K/14343K, external 576K/1020K, paused 2ms+4ms
06-01 03:21:51.387: D/dalvikvm(2653): GC_CONCURRENT freed 54K, 42% free 8448K/14343K, external 576K/1020K, paused 3ms+4ms
06-01 03:21:51.868: I/global(2653): Loaded time zone names for en_US in 406ms.
06-01 03:21:52.118: RestletTrip(2653): Querying: [SOMEURL/SOMENUMBER]
06-01 03:21:52.128: I/org.restlet(2653): Starting the internal [HTTP/1.1] client
06-01 03:21:52.218: D/dalvikvm(2653): GC_CONCURRENT freed 1297K, 36% free 9198K/14343K, external 576K/1020K, paused 3ms+3ms
06-01 03:21:52.218: I/org.restlet(2653): Stopping the internal[HTTP/1.1] client
私が使用するコードは次のとおりです(理解を深めるために削除されています)。
public List<Trip> getTrips() {
// All the ids for the different trips
List<Long> ids = new ArrayList<Long>;
ids.add(new Long(14));
ids.add(new Long(45));
ids.add(new Long(34));
ids.add(new Long(11));
ids.add(new Long(33));
ids.add(new Long(17));
// All the Trips
List<Trip> result = new ArrayList<Trip>();
for (Long tripID : ids) {
Trip trip = getTrip(tripID);
// Add trip to the list
if (trip != null) {
result.add(trip);
}
}
return result;
}
public Trip getTrip(ISettings settings, Long tripID) throws GetTripException, NoSuchElementException {
// Create resource
final TripsResource tripResource = getClientResource(ServerPaths.getTrip(tripID), TripsResource.class);
// Get trip from server
return tripResource.getTrip();
}
私が使用しているエンジン設定は
import org.restlet.engine.Engine;
import org.restlet.ext.httpclient.HttpClientHelper;
import org.restlet.ext.jackson.JacksonConverter;
import org.restlet.ext.json.JsonConverter;
import org.restlet.Client;
import org.restlet.data.Protocol;
protected void setupEngine() {
final Engine engine = Engine.getInstance();
engine.getRegisteredClients().add(new HttpClientHelper(new Client(Protocol.HTTP)));
engine.getRegisteredConverters().add(new JacksonConverter());
engine.getRegisteredConverters().add(new JsonConverter());
}
そのため、GCが原因で取得が非常に遅くなります。どうすればパフォーマンスを向上させることができますか?