-
Notifications
You must be signed in to change notification settings - Fork 122
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
Improve performance of emissary.output.DropOffUtil.processMetadata() by changing loop… #138
Conversation
DropOffUtil.parseMetadata() uses the "new" style for loop syntax which creates an iterator object for each execution of the loop. Iterating over Lists should not be done this way since the "old" style for loop syntax achieves the same result without creating an object. This is evidenced using the 20Meg mysqldump file as an example where parseMetadata() creates 1,773,237 objects representing 56,743,584 bytes unnecessarily as shown in the following screen shots.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. There are no processing differences and this reduces the creation of iterators, resulting in saved memory.
I would like @fbruton to weigh in on this one. I believe he had some concerns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend updating the loop for parentParams
and extended_filetypes
and declaring the data type as an ArrayList
instead of Lists
.
Also, can you profile .clear()
change separately. I'm not sure if that change is going to make much of a difference.
Also, recommend holding off on updating the loop for childObjList
and payloadList
as part of this merge request.
As we continue to profile and look for performance updates, maybe ArrayList
isn't the desired data structure for IBDO records.
if (tld.hasParameter(param)) { | ||
parentTypes.put("1" + param, tld.getStringParameter(param)); | ||
} | ||
} | ||
|
||
for (final IBaseDataObject p : payloadList) { | ||
for (int i = 0; i < payloadList.size(); i++) { | ||
final IBaseDataObject p = payloadList.get(i); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have concerns with the performance of this accessor if the data structure is not an ArrayList
or any other data structure that does not perform at O(1). HDMobileAgent
currently creates an ArrayList
, but the API doesn't prevent the framework from leveraging another data type, such as LinkedList
.
@@ -1085,14 +1091,16 @@ public void processMetadata(final List<IBaseDataObject> payloadList) { | |||
if (p.hasExtractedRecords()) { | |||
final List<IBaseDataObject> childObjList = p.getExtractedRecords(); | |||
Collections.sort(childObjList, new emissary.util.ShortNameComparator()); | |||
for (final IBaseDataObject child : childObjList) { | |||
for (int j = 0; j < childObjList.size(); j++) { | |||
final IBaseDataObject child = childObjList.get(j); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some concerns my previous comment in regards to the potential performance hit if the data type is changed from ArrayList
.
@@ -1030,7 +1033,7 @@ public void processMetadata(final List<IBaseDataObject> payloadList) { | |||
} | |||
|
|||
if (p.getStringParameter("EXTENDED_FILETYPE") == null) { | |||
final List<String> extended_filetypes = new ArrayList<String>(); | |||
extended_filetypes.clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there will be many cases where this could be a long list, but if so, this could potentially use more memory.
To make sure I understand the comments:
|
|
Is the following closer to what you want?
|
…by changing for loop
14268cf
to
c0f907a
Compare
This method is called for each BaseDataObject. The current "for" loop syntax creates a lot of iterator objects and should be changed so that it does not.