Discuss Scratch

Zro716
Scratcher
1000+ posts

Technical question about assets

As far as I know, the content delivery network for assets stores one instance of exact copies. Every asset goes through a hash algorithm which generates the same output for the same input. So every single unchanged Scratch cat costume is stored as only one file on the server, right? And so a slightly varied Scratch cat costume would be stored somewhere else, right?

But what about when an asset is no longer in use, i.e. was deleted from a project? Does that asset remain cached in memory forever or is it removed permanently (until uploaded again)? Does the file server go through a periodic ‘pruning’, where it deletes unused assets? I would be concerned if all the unused files take up several hundred megabytes/several gigabytes of space.

Would prefer a response from an ST member with experience on the infrastructure of Scratch, or if someone is sure they can answer this without an ST response.

As a long time Scratcher, I have found new meaning to the name “Scratch”: for me, it means to “scratch that itch”, to come back again and again to realize new ideas in this toy language, even when I'm capable of creating my projects in real programming languages years later. It's a friend that helped me to pursue programming and get me to enjoy its fruit. I'm certain many others who have walked this path as well have grown fond of its importance in their life.
Dylan5797
Scratcher
1000+ posts

Technical question about assets

Zro716 wrote:

As far as I know, the content delivery network for assets stores one instance of exact copies. Every asset goes through a hash algorithm which generates the same output for the same input. So every single unchanged Scratch cat costume is stored as only one file on the server, right? And so a slightly varied Scratch cat costume would be stored somewhere else, right?

But what about when an asset is no longer in use, i.e. was deleted from a project? Does that asset remain cached in memory forever or is it removed permanently (until uploaded again)? Does the file server go through a periodic ‘pruning’, where it deletes unused assets? I would be concerned if all the unused files take up several hundred megabytes/several gigabytes of space.

Would prefer a response from an ST member with experience on the infrastructure of Scratch, or if someone is sure they can answer this without an ST response.
I am sure I can, I have a lot of experience uploading and experimenting with this API.


As far as I know, assets remain there forever even if all the projects containing them are deleted–an algorithm would have to scan all the projects for asset cleanup, it would cause a degrade of performance on the site whenever someone deleted a project.

Also you can't upload a new version of an existing asset with the same hash if it already exists.

MegaApuTurkUltra
Scratcher
1000+ posts

Technical question about assets

I can upload assets that aren't tied to a project and they stay

$(".box-head")[0].textContent = "committing AT crimes since $whenever"
-Radical-
Scratcher
500+ posts

Technical question about assets

MegaApuTurkUltra wrote:

I can upload assets that aren't tied to a project and they stay
Does that mean they don't stay if they are tied to a project?

(Sorry for asking dumb questions, I'm only 13)

Sincerely, probably me. Maybe myself. Or sometimes I.

Signature last updated on 5/15/16
MathWizz
Scratcher
100+ posts

Technical question about assets

I am pretty confident they stay forever. I don't think going though millions of assets and checking that they are present in a single project's JSON out of millions is practical.

running Chromium 42.0.2311.90 with Flash Player 15.0.0.189 on Arch Linux 3.19.5-1-ck
MathWizzJsScratch && sb.js & Amber (coming soon! maybe)
-Radical-
Scratcher
500+ posts

Technical question about assets

I guess so. Just keep in mind that every single costume, background, or sound file counts as 1 asset. And there's even a URL for it!

So, guess what. Scratch is now a web host!

JK, that would be kinda mean.

Sincerely, probably me. Maybe myself. Or sometimes I.

Signature last updated on 5/15/16
novice27b
Scratcher
1000+ posts

Technical question about assets

-Radical- wrote:

I guess so. Just keep in mind that every single costume, background, or sound file counts as 1 asset. And there's even a URL for it!

So, guess what. Scratch is now a web host!

JK, that would be kinda mean.
Yeah, you can do some interesting things with the CDN API. There is a file size limit however, so you couldn't really use it for anything serious.

It made a security vulnerability in the scratch site possible (https://scratch.mit.edu/discuss/topic/178044/ ) and it also means you can do tricks like this: https://scratch.mit.edu/discuss/topic/179047/ (generating hash collisions).

Last edited by novice27b (May 19, 2016 21:47:35)


i use arch btw
comp09
Scratcher
1000+ posts

Technical question about assets

Speaking of uploading assets to the CDN, has anyone gotten MP3s or PCM (not ADPCM) WAVs to properly play in a Scratch project? It seems older projects have some sounds encoded with PCM instead of the lower quality ADPCM.


Visit the website of Andrew Sun!


MegaApuTurkUltra
Scratcher
1000+ posts

Technical question about assets

comp09 wrote:

Speaking of uploading assets to the CDN, has anyone gotten MP3s or PCM (not ADPCM) WAVs to properly play in a Scratch project? It seems older projects have some sounds encoded with PCM instead of the lower quality ADPCM.
I've put MP3s on the cdn for my high quality sound extension to play

Last edited by MegaApuTurkUltra (May 20, 2016 02:49:30)


$(".box-head")[0].textContent = "committing AT crimes since $whenever"
thisandagain
Forum Moderator
500+ posts

Technical question about assets

Zro716 wrote:

As far as I know, the content delivery network for assets stores one instance of exact copies. Every asset goes through a hash algorithm which generates the same output for the same input. So every single unchanged Scratch cat costume is stored as only one file on the server, right? And so a slightly varied Scratch cat costume would be stored somewhere else, right?

But what about when an asset is no longer in use, i.e. was deleted from a project? Does that asset remain cached in memory forever or is it removed permanently (until uploaded again)? Does the file server go through a periodic ‘pruning’, where it deletes unused assets? I would be concerned if all the unused files take up several hundred megabytes/several gigabytes of space.

Would prefer a response from an ST member with experience on the infrastructure of Scratch, or if someone is sure they can answer this without an ST response.

Assets stay on the server forever even if the associated project is deleted (or as some have mentioned you can even do crazy things like upload assets without a project … which is less than awesome). This has some advantages in terms of limiting the amount of CPU and DB utilization that we need to track assets but does take up a significant amount of disk space (think terabytes rather than gigabytes). @codubee and I are doing some work on the projects and assets systems next month and may be rethinking how this works.
Zro716
Scratcher
1000+ posts

Technical question about assets

Excellent responses, everyone. So my fear of nothing ever being permanently deleted is confirmed, and furthermore, thisandagain shows up telling us that a reconsideration of the CDN is a possibility soon. I should probably close this topic now that it has been resolved. Thanks!

As a long time Scratcher, I have found new meaning to the name “Scratch”: for me, it means to “scratch that itch”, to come back again and again to realize new ideas in this toy language, even when I'm capable of creating my projects in real programming languages years later. It's a friend that helped me to pursue programming and get me to enjoy its fruit. I'm certain many others who have walked this path as well have grown fond of its importance in their life.

Powered by DjangoBB