This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 19761 - Dictionary type for MIDIMessage is likely a performance issue
Summary: Dictionary type for MIDIMessage is likely a performance issue
Status: CLOSED FIXED
Alias: None
Product: AudioWG
Classification: Unclassified
Component: MIDI API (show other bugs)
Version: unspecified
Hardware: All All
: P2 normal
Target Milestone: TBD
Assignee: Chris Wilson
QA Contact: public-audio
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-29 19:39 UTC by Chris Wilson
Modified: 2012-11-19 16:03 UTC (History)
2 users (show)

See Also:


Attachments

Description Chris Wilson 2012-10-29 19:39:40 UTC
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.
Comment 1 Jussi Kalliokoski 2012-10-31 01:04:45 UTC
(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)`?
Comment 2 Chris Wilson 2012-10-31 18:19:41 UTC
(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.
Comment 3 Jussi Kalliokoski 2012-11-01 09:37:41 UTC
(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?
Comment 4 Chris Wilson 2012-11-01 15:32:34 UTC
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.
Comment 5 Chris Wilson 2012-11-01 23:58:10 UTC
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
Comment 6 Olivier Thereaux 2012-11-19 16:03:28 UTC
No objection in 2 weeks since resolution. Closing.