Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 355263 - [otre] avoid performance penalty due to eager creation of _OT$roleSet
Summary: [otre] avoid performance penalty due to eager creation of _OT$roleSet
Status: VERIFIED FIXED
Alias: None
Product: Objectteams
Classification: Tools
Component: OTJ (show other bugs)
Version: 2.0   Edit
Hardware: Other Linux
: P3 normal (vote)
Target Milestone: 2.1 M2   Edit
Assignee: Stephan Herrmann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-08-19 15:44 EDT by Stephan Herrmann CLA
Modified: 2012-06-05 17:43 EDT (History)
1 user (show)

See Also:


Attachments
Fix by deletion (907 bytes, patch)
2011-08-19 16:14 EDT, Stephan Herrmann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Stephan Herrmann CLA 2011-08-19 15:44:35 EDT
When a base object is created to which a role is bound, the _OT$roleSet
is instantiated eagerly, imposing an unnecessary performance penalty,
the role set will be created on-demand during _OT$addRole() any way.
Comment 1 Stephan Herrmann CLA 2011-08-19 15:57:13 EDT
Here's a test program I used for ad-hoc micro-measurements:

public team class TeamClass {
	protected class R playedBy BaseClass { }
}
public class BaseClass {
	static int N=10000;
	static int R=100;
	public static void main(String[] args) {
		new TeamClass().activate(); // but no callin!
		long accu = 0L;
		for (int r=0;r<R; r++) {
			BaseClass bs[] = new BaseClass[N];
			long start = System.nanoTime();
			for (int i=0; i<N; i++)
				bs[i] = new BaseClass();
			if (r < 10) continue; // warm-up, don't count
			long duration = System.nanoTime()-start;
			System.out.println("Duration = "+duration);
			accu += duration;
		}
		System.out.println("Mean="+(accu/(R-10)));
	}
}

Preliminary results show a 3.5 speedup by avoiding the instantiation of
the role set.

Currently running the full OTJLD test suite to validate the change.
Comment 2 Stephan Herrmann CLA 2011-08-19 16:14:00 EDT
Created attachment 201836 [details]
Fix by deletion

It seems to be as easy as that: just delete the block creating
the instantiation instructions. 
All OTJLD tests pass with this patch.
Comment 3 Stephan Herrmann CLA 2011-08-19 16:17:27 EDT
Patch has been committed for 2.1M2 (r1907).
Comment 4 Stephan Herrmann CLA 2012-06-05 17:43:36 EDT
Verified for 2.1 by inspecting the generated byte code.