Closed
Bug 573452
Opened 14 years ago
Closed 13 years ago
Type-specialized Vector methods (AS3 implementations)
Categories
(Tamarin Graveyard :: Library, defect, P3)
Tamarin Graveyard
Library
Tracking
(Not tracked)
RESOLVED
FIXED
Q4 11 - Anza
People
(Reporter: lhansen, Assigned: lhansen)
References
Details
(Whiteboard: PACMAN, has-patch)
Attachments
(2 files, 4 obsolete files)
(For some background see bug #477139.) The AS3-implemented vector methods are written in a type-unspecialized way. There may be some benefits to specializing them to specific vector types, since we'd get early binding that way. In the 'push' method there are several accesses to 'this' but the code has no knowledge of what its type is. To do better we'd need to specialize 'push' for each of the Vector implementation types.
Assignee | ||
Updated•14 years ago
|
Whiteboard: PACMAN
Flags: flashplayer-qrb+
Priority: -- → P3
Target Milestone: --- → flash10.2
Updated•14 years ago
|
Blocks: vector-tracker
Following is the comparison between type specialize vector and untyped vector for different types type push typed push untyped uint 45 39 int 45 39 double 42 37 object 18 17 type join typed join untyped uint 10 10 int 10 10 double 4 4 object 4 4 type shift typed shift untyped uint 3 3 int 3 3 double 1 1 object 2 2 type toLocaleString typed toLocaleString untyped uint 9 9 int 9 9 double 4 4 object 6 6 Only push seems to have performance improvement.
Comment on attachment 473405 [details]
Benchmark files to test vector push,join,shift, toLocaleString
Need feedback whether benchmark files are proper or not.
Attachment #473405 -
Flags: feedback?(stejohns)
Comment on attachment 473409 [details] [diff] [review] Patch to Type-specialize vector push,join,shift and toLocaleString. Please refer comment #2 for results I got.
Attachment #473409 -
Flags: feedback?(stejohns)
Comment 5•14 years ago
|
||
Comment on attachment 473405 [details]
Benchmark files to test vector push,join,shift, toLocaleString
Do these actually work? I don't think that
var a = new <int>[];
is legal syntax, it should be
var a = new Vector.<int>[];
Likewise, you can't create a new Vector with a literal, as you can with an array, so
var a = new <int>[0,1,2,3,4,5,6,7,8,9];
won't work.
*Conceptually* this looks fine, though, but please submit tested code next time :-)
Some other minor nits:
You should include asmicro/driver.as rather than replicating the TEST3 function though.
Two style isseus:
-- all new code should use spaces, not tabs. 4 spaces is preferred indentation.
-- preferred style in AS3 is
function foo()
{
rather than
function foo() {
Attachment #473405 -
Flags: feedback?(stejohns) → feedback+
Comment 6•14 years ago
|
||
Comment on attachment 473409 [details] [diff] [review] Patch to Type-specialize vector push,join,shift and toLocaleString. You don't need to do var v:Vector$object = this; in the specialized versions; we already know that 'this' is a Vector$object (or whatever), you should be able to just use 'this' directly. Otherwise, the patch looks plausible with minor objections noted below. The loop structure is awkward, but I guess that's how the previous code was... feels like it could be tightened, but this isn't essential. Also, see the style nits from the other patch on AS3 formatting and tab usage; additionally, please prefer the style if (cond) { to if( cond ) { and insert a space between // and the beginning of the comment text.
Attachment #473409 -
Flags: feedback?(stejohns) → feedback-
Comment 7•14 years ago
|
||
(In reply to comment #5) > Comment on attachment 473405 [details] > Benchmark files to test vector push,join,shift, toLocaleString > > Do these actually work? I don't think that > > var a = new <int>[]; > > is legal syntax, it should be > > var a = new Vector.<int>[]; > > Likewise, you can't create a new Vector with a literal, as you can with an > array, so > > var a = new <int>[0,1,2,3,4,5,6,7,8,9]; > > won't work. Both var a = new <int>[0,1]; var a = new Vector.<int>[0,1]; passes through strict mode compilation, the generated abc is a bit different (don't know why though). Is there a reason we might prefer one over the other for benchmarks (Vector.<int> looks like the faster one)?
Assignee | ||
Comment 8•14 years ago
|
||
(In reply to comment #5) > Comment on attachment 473405 [details] > Benchmark files to test vector push,join,shift, toLocaleString > > Do these actually work? I don't think that > > var a = new <int>[]; > > is legal syntax, it should be > > var a = new Vector.<int>[]; That's not true. The vector literal syntax is 'new <int>[E1, ..., En]' and has been supported for some time. Jimmy, please note carefully that new Vector.<int>[1,2,3] *does not mean what you think it means*. Specificially, it parenthesizes like this: (new Vector.<int>)[1,2,3] which is to say, fetch the element named "3" from a new vector containing no elements (and will result in a range error exception being thrown if you try to run it).
Assignee | ||
Comment 9•14 years ago
|
||
I should add that the Vector.<T> constructor takes zero or one arguments; if one argument is provided it needs to be the length of the vector. You can also convert an Array instance to Vector: Vector.<int>([1,2,3]) It is a known performance bug (https://bugzilla.mozilla.org/show_bug.cgi?id=532690#c16) that this is actually faster than the equivalent new <int>[1,2,3]
Comment 10•14 years ago
|
||
(In reply to comment #6) > Comment on attachment 473409 [details] [diff] [review] > Patch to Type-specialize vector push,join,shift and toLocaleString. > > You don't need to do > > var v:Vector$object = this; > > in the specialized versions; we already know that 'this' is a Vector$object (or > whatever), you should be able to just use 'this' directly. But https://bugzilla.mozilla.org/show_bug.cgi?id=477139#c10 says that 'this' is untyped if we use it directly. So we have to assign to appropriate typed variable. Am I missing anything here?
Comment 11•14 years ago
|
||
uses driver.as and style changes.
Attachment #473405 -
Attachment is obsolete: true
Comment 12•14 years ago
|
||
Fixed all comments from Steven Johnson except removal of var v:Vector$object = this. Without reassigning 'this' there is no performance benefit. Following are the untyped vs typed performance results: untyped typed uint 37 45 int 39 45 double 36 43 object 17 18 We didnt see any performance improvement for any other vector functions. So this patch only has changes for vector.push.
Attachment #473409 -
Attachment is obsolete: true
Attachment #478206 -
Flags: feedback?(stejohns)
Attachment #478206 -
Flags: feedback?(edwsmith)
Comment 13•14 years ago
|
||
Fix problem with previous attachment.
Attachment #478206 -
Attachment is obsolete: true
Attachment #478208 -
Flags: feedback?(stejohns)
Attachment #478208 -
Flags: feedback?(edwsmith)
Attachment #478206 -
Flags: feedback?(stejohns)
Attachment #478206 -
Flags: feedback?(edwsmith)
Assignee | ||
Updated•14 years ago
|
Attachment #478205 -
Attachment mime type: application/octet-stream → text/plain
Comment 14•14 years ago
|
||
Comment on attachment 478208 [details] [diff] [review] Patch for Type Specialized vector push A comment on each copy mentioning that any changes should be propagated to the other copies, would be useful. var v:Vector$object = this; ^^^^^^^^^^^^^ It's odd to see type annotations like this in AS3. Should it be v:Vector.<Object> instead? Is the bytecode the same either way? The benchmark #s look promising so far.
Attachment #478208 -
Flags: feedback?(edwsmith) → feedback+
Updated•14 years ago
|
Assignee: nobody → sakula
Comment 15•14 years ago
|
||
(In reply to comment #10) > (In reply to comment #6) > > Comment on attachment 473409 [details] [diff] [review] [details] > > Patch to Type-specialize vector push,join,shift and toLocaleString. > > > > You don't need to do > > > > var v:Vector$object = this; > > > > in the specialized versions; we already know that 'this' is a Vector$object (or > > whatever), you should be able to just use 'this' directly. > > But https://bugzilla.mozilla.org/show_bug.cgi?id=477139#c10 says that 'this' is > untyped if we use it directly. So we have to assign to appropriate typed > variable. Am I missing anything here? FYI, after reading the dialogue on this bug, I figured it made sense to file a bug against ASC, since Steven's reasoning sounded good to me: https://bugs.adobe.com/jira/browse/ASC-4138
Comment 16•14 years ago
|
||
(In reply to comment #10) > But https://bugzilla.mozilla.org/show_bug.cgi?id=477139#c10 says that 'this' is > untyped if we use it directly. So we have to assign to appropriate typed > variable. Am I missing anything here? In those cases that is true, since 'this' is the base class, not the specialized class. But in this case the method lies in the specialized class, so 'this' is known to be that class. (Or should be -- if not, ASC is doing something mighty dumb here.) (In reply to comment #15) > FYI, after reading the dialogue on this bug, I figured it made sense to file a > bug against ASC, since Steven's reasoning sounded good to me: Ouch! Ignore my comment above, I guess -- seems mighty weird for 'this' to be untyped, but if ASC is compiling that way, then my comment is clearly wrong. (It's worth adding comments to the code to this effect, in case someone else makes the same assumption I did....)
Comment 17•14 years ago
|
||
Comment on attachment 478208 [details] [diff] [review] Patch for Type Specialized vector push Probably should add a comment about why the explicit "var v:Vector$object = this;" is necessary (ie, compiler issue)
Attachment #478208 -
Flags: feedback?(stejohns) → feedback+
Comment 18•14 years ago
|
||
(In reply to comment #14) > Comment on attachment 478208 [details] [diff] [review] > Patch for Type Specialized vector push > > A comment on each copy mentioning that any changes should be propagated to the > other copies, would be useful. > > var v:Vector$object = this; > ^^^^^^^^^^^^^ > > It's odd to see type annotations like this in AS3. Should it be > v:Vector.<Object> instead? Is the bytecode the same either way? > > The benchmark #s look promising so far. The '$' syntax is used through out "vector.as" file, i.e why, I also used the same syntax. But compiler is allowing this syntax only in the vector builtin class. If I use '$' syntax in any other user classes, conmpiler is generating error. What is the difference between the two syntaxes? Should I change it to Vector.<Object>?
Comment 19•14 years ago
|
||
Incorporated Edwin's and Steve's comments. No one has come back on the vector.<Object> vs vector$object syntax. So, that is unchanged.
Attachment #478208 -
Attachment is obsolete: true
Attachment #480885 -
Flags: feedback?(stejohns)
Attachment #480885 -
Flags: feedback?(edwsmith)
Updated•14 years ago
|
Attachment #480885 -
Flags: feedback?(edwsmith) → feedback?(wsharp)
Comment 20•14 years ago
|
||
Comment on attachment 480885 [details] [diff] [review] Patch to Type-specialize vector push Looks good to me.
Attachment #480885 -
Flags: feedback?(wsharp) → feedback+
Updated•14 years ago
|
Attachment #480885 -
Flags: feedback?(stejohns) → feedback+
Comment 21•14 years ago
|
||
(In reply to comment #20) > Comment on attachment 480885 [details] [diff] [review] > Patch to Type-specialize vector push > > Looks good to me. (In reply to comment #20) > Comment on attachment 480885 [details] [diff] [review] > Patch to Type-specialize vector push > > Looks good to me. Is the patch is ok to check-in or should it go through the review and super review. Anyways I dont have check-in rights. If it is ready for check-in, can anyone do it for me.
Comment 22•13 years ago
|
||
To Steven to land.
Assignee: sakula → stejohns
Flags: flashplayer-bug-
Whiteboard: PACMAN → PACMAN, has-patch, must-fix-candidate
Flags: flashplayer-injection-
Target Milestone: Q3 11 - Serrano → Q4 11 - Anza
Assignee | ||
Updated•13 years ago
|
Assignee: stejohns → lhansen
Status: NEW → ASSIGNED
Whiteboard: PACMAN, has-patch, must-fix-candidate → PACMAN, has-patch
Assignee | ||
Updated•13 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Comment 23•13 years ago
|
||
changeset: 6563:0c942416e68f user: Lars T Hansen <lhansen@adobe.com> summary: Fix 573452 - Type-specialized Vector methods (AS3 implementations), slightly cleaned up and re-tested (patch=sakula, f=wsharp, f=stejohns, push=lhansen) http://hg.mozilla.org/tamarin-redux/rev/0c942416e68f
Comment 24•13 years ago
|
||
QE: this needs test media to make sure that the code paths are touched/working
Flags: in-testsuite?
You need to log in
before you can comment on or make changes to this bug.
Description
•