We've had this discussion in a couple of places. Here's a slight attempt to consolidate the concerns and possible approaches.
Concerns:
Possible approaches we've started thinking about:
Haven't really thought about how each of these interact with undo/redo. None of them seem particularly great, but one should probably work out.
Assigning @picklesrus @rachel-fenichel @thisandagain for feedback.
undo/redo feels to me like it should be per-sprite--so when you switch to a specific sprite, you switch back to its undo/redo stack as well.
Dealing with diverging toolboxes/flyouts: we should assume that sprites/targets may have different sets of blocks, different categories, different variables and procedures. For example, the stage in Scratch 2.0 doesn't have many blocks that sprites do. And, sprites can have "local" variables and lists.
In Scratch 2.0 the sprites and stages have the same categories, but different blocks inside them. Is this likely to change?
Re: undo/redo. Agreed. Per-sprite seems reasonable. The alternative would be we'd have to switch between active sprite in the undo/redo stack. One unfortunate thing we have to think about is how undo/redo reacts with sprite adding/removing. When you delete a sprite, how do you undo that? Maybe there should be a separate undo/redo stack for that part of the editor...
I think it's probably safe to assume that the categories are consistent across sprites/stage/etc.
Below is a simple distribution of both block and sprite counts to assist in understanding the performance expectations of Scratch projects. This data reflects the last 300,000 projects (both shared and unshared) as accessed on August 8th, 2016. The y-axis ("Number of Projects") is Log.
Min: 0
Max: 3908
Median: 24
90th Percentile: 1463
Power Regression: 1.0293e7*x^(-2.0645)

Min: 0
Max: 999
Median: 30
90th Percentile: 364
Power Regression: 2.0488e7*x^(-2.6774)

/cc @tmickel @cwillisf @rachel-fenichel @picklesrus
@thisandagain @cwillisf @rachel-fenichel @picklesrus
Here is a starting spreadsheet of some benchmarking of the current state of things:
https://docs.google.com/spreadsheets/d/1rbHMnboLuq3IJUrfguIzyF81Syq1WWgK4B9cpo3RPrc/edit?usp=sharing
Summary:
Re: categories changing between programmable objects - We've discussed some use cases around this, such as having multiple robots with different functionality or characters with different move sets. I'm not aware of anyone actually doing this, though, so low priority.
Thanks @tmickel !
I'm also curious about your two questions on the "Load / Save Blocks to 1 Workspace" sheet:
clear() so slow?In terms of "Workspace Generation Times", do we have an understanding of what that looks like in Scratch 2.0? 5895.5ms seems slow for 1000 blocks, but I'm not sure how we benchmark today.
I'm pretty sure clear is slow because we've never bothered to make it fast. It calls dispose() on every top level block in turn, and each block's dispose does stuff like resize the workspace's svg (because the contents have changed). There's also just a lot of DOM manipulation happening there.
Clear has nothing to do with XML serialization.
There's a lot of room to make that faster, and most of it looks pretty simple.
Clear has nothing to do with XML serialization.
Sorry @rachel-fenichel , I should have been more precise in my comment. I added a clarification above.
As per discussion today we are going to proceed with the "single workspace with saving / loading" model for now.
In the current implementation, we're avoiding serialization on switch (since the VM already has a representation of the workspace). This also means no extra serialized copy has to be stored in memory.
So, I think some of the action items here are:
workspace.clear - do we need them, are they possible/easy?Blockly.Xml.textToDom and Blockly.Xml.domToWorkspace - do we need them, are they possible/easy?moving to backlog for additional questions
Most helpful comment
Overview
Below is a simple distribution of both block and sprite counts to assist in understanding the performance expectations of Scratch projects. This data reflects the last 300,000 projects (both shared and unshared) as accessed on August 8th, 2016. The y-axis ("Number of Projects") is Log.
Block Frequency Distribution
Sprite Frequency Distribution
/cc @tmickel @cwillisf @rachel-fenichel @picklesrus