jussi-kalliokoski / webmidi-issues

A test repo for importing the issues from bugzilla
0 stars 0 forks source link

Dictionary type for MIDIMessage is likely a performance issue #32

Closed jussi-kalliokoski closed 11 years ago

jussi-kalliokoski commented 11 years ago

Originally reported on W3C Bugzilla ISSUE-19761 Mon, 29 Oct 2012 19:39:40 GMT Reported by Chris Wilson Assigned to Chris Wilson

MIDIMessage is currently defined as a dictionary. In the case of thousands of MIDIMessages being pumped through the system, that would be less efficient than a type that can be explicitly typecast.

jussi-kalliokoski commented 11 years ago

Original comment by Jussi Kalliokoski on W3C Bugzilla. Wed, 31 Oct 2012 01:04:45 GMT

(In reply to comment #0)

MIDIMessage is currently defined as a dictionary. In the case of thousands of MIDIMessages being pumped through the system, that would be less efficient than a type that can be explicitly typecast.

I'm not sure what you mean by a type that can be explicitly typecast, could you clarify? Do you mean using a constructed type instead, like new MIDIMessage(data, timestamp)?

jussi-kalliokoski commented 11 years ago

Original comment by Chris Wilson on W3C Bugzilla. Wed, 31 Oct 2012 18:19:41 GMT

(In reply to comment #1)

I'm not sure what you mean by a type that can be explicitly typecast, could you clarify? Do you mean using a constructed type instead, like new MIDIMessage(data, timestamp)?

In essence, except the other way around. A Dictionary type just means an Object with those members; unfortunately, they can be organized in any way, and the members need to be "searched" for; these types cannot be optimized down to essentially a struct behind the scenes. I received feedback that it is best to avoid Dictionary types for basic structures unless absolutely necessary.

jussi-kalliokoski commented 11 years ago

Original comment by Jussi Kalliokoski on W3C Bugzilla. Thu, 01 Nov 2012 09:37:41 GMT

(In reply to comment #2)

(In reply to comment #1)

I'm not sure what you mean by a type that can be explicitly typecast, could you clarify? Do you mean using a constructed type instead, like new MIDIMessage(data, timestamp)?

In essence, except the other way around. A Dictionary type just means an Object with those members; unfortunately, they can be organized in any way, and the members need to be "searched" for; these types cannot be optimized down to essentially a struct behind the scenes. I received feedback that it is best to avoid Dictionary types for basic structures unless absolutely necessary.

True. Since we've already simplified the MIDIMessage interface to just contain the data and the timestamp, we might take it a step further, i.e. change the send(MIDIMessage) signature to be send(Uint8Array data, DOMHighResTimeStamp? timestamp), and change the MIDIMessage from a dictionary to an interface (since dictionary makes no sense if it's not ever created by the user).

Thoughts?

jussi-kalliokoski commented 11 years ago

Original comment by Chris Wilson on W3C Bugzilla. Thu, 01 Nov 2012 15:32:34 GMT

That's pretty much the conclusion I'd reached as the solution for https://www.w3.org/Bugs/Public/show_bug.cgi?id=18764 - i.e. as the consolidation of send() and sendMIDIMessage().

I'll edit it later today.

jussi-kalliokoski commented 11 years ago

Original comment by Chris Wilson on W3C Bugzilla. Thu, 01 Nov 2012 23:58:10 GMT

Moved to interface (although the difference is irrelevant, now, since MIDIMessage objects are only created inside the implementation, not by developers.

https://dvcs.w3.org/hg/audio/rev/f939eca58e74

jussi-kalliokoski commented 11 years ago

Original comment by Olivier Thereaux on W3C Bugzilla. Mon, 19 Nov 2012 16:03:28 GMT

No objection in 2 weeks since resolution. Closing.