Skip to content

Commit

Permalink
[pegasus] Remove unnecessary AnyRecord allocation in CollectionRespon…
Browse files Browse the repository at this point in the history
…seBuilder

CollectionResponseBuilder.buildRestLiResponseData method wraps a DataMap object into a new AnyRecord object, but that AnyRecord object is never used despite of redirecting the wrapped DataMap object to a paging metadata. This adds about 2% allocation pressure based on profile, and could be avoided by passing the DataMap object to paging metadata directly.
Note this allocation could be optimized via escape analysis if the method becomes hot and gets compiled by C2, but this fix will still remove extra computation (i.e. object initialization).

RB=887380
G=si-dev
R=kbalasub,sihde,mnchen,dhoa,xma,kvidhani,ssheng
A=kbalasub
  • Loading branch information
Chen Li(Performance Engineering) committed Dec 21, 2016
1 parent 399ec2d commit d75cfbe
Showing 1 changed file with 2 additions and 3 deletions.
Expand Up @@ -128,9 +128,8 @@ private static RestLiResponseData buildRestLiResponseData(final RestRequest requ
//If the client decides they want total in their paging response, then the resource method will see total in their
//paging path spec and then decide to set total to a non null value. We will then also include it when we project
//paging.
final RecordTemplate anyRecord = new AnyRecord(RestUtils.projectFields(paging.data(),
ProjectionMode.AUTOMATIC, resourceContext.getPagingProjectionMask()));
final CollectionMetadata projectedPaging = new CollectionMetadata(anyRecord.data());
final CollectionMetadata projectedPaging = new CollectionMetadata(RestUtils.projectFields(paging.data(),
ProjectionMode.AUTOMATIC, resourceContext.getPagingProjectionMask()));

//For root object entities
List<AnyRecord> processedElements = new ArrayList<AnyRecord>(elements.size());
Expand Down

0 comments on commit d75cfbe

Please sign in to comment.