Community
Participate
Working Groups
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.
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.
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.
Patch has been committed for 2.1M2 (r1907).
Verified for 2.1 by inspecting the generated byte code.