Spotify excessively writing to drive
community.spotify.com
community.spotify.com
On OS X, Open /Applications/Spotify.app/Contents/MacOS/Spotify in a hex editor.
Search for "VACUUM;" Replace with "xxxxxx;"
On Windows, apparently the key "VACUUM;" string is in libcef.dll but I don't have a Windows system to see if editing it the same way provides a workaround like on OS X.
I used hexcurse from homebrew. After opening the file hit tab once to switch to the ASCII side, Control-F to search for VACUUM;, then type "x" six times to overwrite each character. Quit and save.
EDIT: fixes
I didn't count the x's in the quoted text that I copied from the thread.
Also, I'm assuming this has to be done after every update, and since Spotify auto-updates, not so convenient...
Think of it roughly as defragmentation. You're trading work (in the form of writes and CPU) for reclaimed space.
Unless SQLite has some semantics around it, replacing it with "xxxxxx;" will likely just cause it to run a bad command...might be more correct to replace it with something like "------;" (comment characters).
Spotify stores a local SQLite database file (by default on a Mac it's at ~/Library/Application Support/Spotify/PersistentCache/mercury.db )
The file is only about ~100MB (on my computer). With databases, you issue a vacuum command to defragment a database (reclaim space from deleted/updated rows, re-sort the data, etc). SQLite's VACUUM behavior basically just recreates the entire database from scratch in a temp file, then replaces the live file with that[1]. It makes the file smaller and more efficient to run queries against. Spotify must be triggering a VACUUM statement too aggressively (possibly after every change), rather than on a periodic schedule or after a certain amount of fragmentation. By breaking the VACUUM statement with this solution, you prevent the database from getting recreated so frequently. The file itself will grow slowly (since you're not reclaiming free space like a VACUUM would) and possibly slow down queries against the database, but that sounds like a far better tradeoff than excessive wear on the drive from recreating the file so often.
sqlite3 mercury.db vacuum;
from
https://sqlite.org/download.htmlOn the other hand it fits the picture: Their clients/apps on multiple platforms are very underwhelming. The abandoned rdio apps back from 2014 (or when did they close?) would offer a better experiment in almost any aspect.
if (time_since_last_vacuum > 3600 /* seconds */) {
go_hogwild_on_io();
} else {
be_nice();
}It is disheartening to those of us who enjoy writing decent software, particularly decent native software.
#!/usr/bin/python
target = "/Applications/Spotify.app/Contents/MacOS/Spotify"
with open(target) as infile:
bytes = infile.read()
with open("./Spotify", "wb") as backup:
backup.write(bytes)
fixed = bytes.replace("VACUUM;", "xxxxxx;")
with open (target, "wb") as outfile:
outfile.write(fixed)Thanks logicallee! I definitely need to be more judicious about time management, so I appreciated your comment!
Just because something could be fun to do if you didn't have anythign else to do and were bored out of your mind, doesn't mean it's worth doing, ever.
That's how I took it.
Also, since you are on a Mac, I would use launchd jobs and make it less brute-force by scheduling the job changing the file on writes to the Applications/Spotify.app/Contents/MacOS/ directory.
$ cat /usr/local/bin/spotify-turn-off-vacuum
#!/usr/bin/env python2
target = "/usr/bin/spotify"
with open(target) as infile:
bytes = infile.read()
with open(target+".bak", "wb") as backup:
backup.write(bytes)
fixed = bytes.replace("VACUUM;", "xxxxxx;")
with open (target, "wb") as outfile:
outfile.write(fixed)
$ cat /etc/apt/apt.conf.d/99spotify-turn-off-vacuum
DPkg::Post-Invoke {"/usr/local/bin/spotify-turn-off-vacuum";};perl -pi -e 's/VACUUM/xxxxxx/g' /Applications/Spotify.app/Contents/MacOS/Spotify
And once they saw it open the sqlite.db, all they needed to do was run sqlite3 on the command line against the DB file and see if there was history in the file.
It is possible that the Android client does the same as sqlite3 is the underlying database format for apps and is very easy to use.
or
SET @noop=0
or
NULL; -- works in pg at least
seem like good possibilities.
... and not one engagement from Spotify themselves on the thread. Seems like pretty poor customer support to me.
They constantly kept redirecting me to their forums or to their FAQ's when my payment wasn't going through.
Finally I raised a support request and awaited their reply. That was a few months ago. Since I didn't hear back from them I gave my money to Google play music (even though I'm not a fan of the google play UI or the app).
Also, how is music discovery there? Spotify is crazy good with their discover weekly feature.
EDIT I am interested are you downvoting because you (1) think I am wrong, or (2) don't like that it contains adverts, or (3) don't mind it containing adverts and think that this is irrelevant?
[1] http://www.adweek.com/news/technology/spotify-will-now-let-b...
Apple Music's discovery is awful (although I guess it doesn't know me as well as Spotify does)
I started my Google play music subscription two days ago. Their customer support beyond pre-recorded rhetoric is abysmal.
The app, at least on Android, is very immature, though.
Has a better Asian selection than Spotify, at least.
That annoyed me to no end as well. I had to get another app to forcifully intercept any play call and trigger a pre-defined application instead. Which is... not optimal. I'm glad this thread is on HN, bugs with Spotify clients not getting fixed for months/years have annoyed me since I signed up in 2008.
Was it closed as Fixed? Duplicate? Wontfix?
This is the kind of bug that should have been easily caught by automated regression testing. It wasn't. That should have been easily caught by a pre-release QA process. It wasn't. The kind that, if it it sneaked into a release, should have been triggered a rollback or a quick patch. It didn't.
Instead, they left this ugly bug in place for months. Despite dozens of complaints of their support forums, containing hundreds of posts. And throughout, I never saw a single official response from a Spotify employee. The only communication was hearsay through volunteer moderators, who said it was being "worked on", but with no suggestion of why it wasn't being fixed sooner, or when it actually would be.
Spotify push out updates to their client almost every few days, but it's clear their software development process is garbage, and that their developers are either unwilling, or unable to prioritise basic bug fixes. If I had to guess, I'd suggest that it's a combination of technical debt and bad processes inherited from their startup days, combined with a management focus on features that support monetisation goals rather than basic maintenance.
I wish it was that. I'm not claiming to know, but AFAIR they've done at least two overhauls which I believe changed both dependencies, interface and logic, which suggests they had at least the opportunity to clean out any technical debt.
But for sure, something in the client development is broken. I remember reporting that bug too, as well as others.
In my experience, when things are this bad, the prioritisation is being made outside of the development team. Working with a super buggy codebase is unpleasant, demoralising work. Developers don't do it by choice.
Just noticed, thanks to this comment, that it's FINALLY been fixed. Excellent
For a service I love dearly and have been using for 8 years, both their client applications and their support thereof has always been astoundingly lacking.
I've reported numerous bugs, and they almost always go unanswered for years, while some community elevated user will respond in a well-meaning but non-relevant answer, suggesting some run-of-the-mill IT tech solution, without any insight into the actual problem nor the Spotify tech.
I have rarely ever seen a Spotify rep taking client bugs seriously. Which is a shame.
But on that note: Has anyone tried Tomahawk? Or any other alternative client? I've been meaning to try something else but haven't gotten around to it.
"Isn't installing Spotify in a regular HDD an option?"
Just completely ignore the problem and find a way to let you pretend it doesn't exist.
I didn't even check, but that is indeed a very accurate synecdoche of their support forum at large. Good catch.
EDIT: Just tried to do so, and the spotify installer doesn't let you choose where to install.
See http://blog.scaleprocess.net/spotify-heavy-io-problem/
Besides that, a lot of times setting a diff location for your cache does NOT move the cache. I had to use a symlink.
It's the VACUUM'ing of the SQLite database in that folder that's the problem. Moving that destination to your other drive should hopefully move the IO with it (I don't have a second drive to test with)
Obviously HN has a techie lean, and we dislike "bad" software but in the real world this matters little to 90+% of Spotify's customer base I'm sure.
It's so frustrating and totally avoidable on their part (just a check-in saying "we're still not sure what the cause is but we are looking at it" would make such a difference)
And despite all this, I am still using their service. None of the competitors have what I want/need.
There's probably some way to get that info too, but of course I killed the app as soon as I saw what was going on, so it's too late!
Edit: uptime does give it a firm upper bound, at least. My current uptime is a bit over 12 days. So that's an average of 80GB/day at least, more if I started Spotify sometime after boot.
ps aux | grep ' /Applications/Spotify.app/Contents/MacOS/Spotify$' | awk '{print $9}'
"We've seen some questions in our Community around the amount of written data using the Spotify client on desktop. These have been reviewed and any potential concerns have now been addressed in version 1.0.42, currently rolling out to all users."
So... sounds like it's fixed? If so, good job on making a fuss, everybody!
I don't list to _that much_ music?!
Spotify launched 10 days ago, 127MB written, 1.29GB read.
maybe relevant, I'm running Mavericks.
Pretty heavy usage, though.
vs
Spotify R 100MB/W 400MB
What in blazes are the offending programs doing? If it were swap, then one should expect an 1:1 ratio between R and W, but that? Seriously?
>Errors didn't strike the Samsung 840 Series until after 300TB of writes, and it took over 700TB to induce the first failures. The fact that the 840 Pro exceeded 2.4PB is nothing short of amazing, even if that achievement is also kind of academic.
http://techreport.com/review/27909/the-ssd-endurance-experim...
From a test I've seen, SSDs can start showing issues at the 250TB mark. Wouldn't be a huge issue if Spotify were the only problem child, but remember when Firefox (and probably Chrome) were/are doing excessive SSD writes as well? And this past week, the League of Legends client was revealed to be too. If they all do 100GB per day like how Spotify does in this example, then your SSD could have issues after just under 2.5 years, which is nuts.
The above is a super rough estimate as Spotify usage will vary and how bad the League client and browsers are and how often people use those vary as well, but this could just be the beginning. What if Word decided to be SSD write heavy too? Or Adobe Reader? Or iTunes? Or whatever else it is people use.
Firefox comes pre-configured with a time of 15 seconds intervals, that is, every 15 seconds it writes a few KBs of data just to reopen your session, no matter what' activity you're doing with the browser (or if doing nothing at all). At the end of the day it ammounts to a few GB's in writes, depending on your browsers usage.
So it's not crazy/paranoid/weird to asume that this is becoming more or less "standard" behaviour.
It simply doesn't matter that SSDs will be ok. It's being wasteful of system resources. Software should not waste system resources.
Others might have, but I don't think it was ever encouraged to write daft loops or short timers to write data.
It is interesting that the styles of writing code (eg doing dynamic casts at runtime a lot) has real impacts on performance and speed. Stroustrup wrote an interesting paper (must find it) where he encouraged static code generation rather than runtime dynamic checks all the time. It means we have to think a bit harder when designing software and writing it, but it is worth it for all our sakes (less CPU time to do the same thing, less power used etc)
You can block all ads with uBlock Origin too.
I can't find a reason to download the application now.
It depends a lot on the record, but on a gorillaz track ("feel good inc") I could hear it very well.
Ironically the tracks quality on spotify is quite bad, because the label provided crap to them.
edit: reply from the support was:
~320 kbps (only available to Premium subscribers) [...]
Also, we only make the music available in whatever form it’s given to us by the artists or labels.
edit: good abx test for spotify standard quality: http://abx.digitalfeed.net/spotify.htmlI wonder though, if I would hear it for the kind of music I listen too (more technoid or classic). James Blake was the closest sample, but rather easy on the codec I guess.
Here (James Blake and alike) much producing goes in to making things sound "punchy", so you limit the frequency range of most things to keep a clear sound (e.g. a high cymbal will be stripped of possible lower frequencies) and you do tricks like cross-chaining: when the base drum hits you turn the volume of the rest of the track down. And than loads of compression, making silent parts louder.
Yeah if it were up to me they should get rid of the free tier altogether. It's basically people living off the back of paid users, which I am one of, and not wanting to compensate artists. They might as well be using the pirate bay.
"We've seen some questions in our Community around the amount of written data using the Spotify client on desktop. These have been reviewed and any potential concerns have now been addressed in version 1.0.42, currently rolling out to all users."
https://community.spotify.com/t5/Ongoing-Issues/Major-I-O-wr...
I really hope they've fixed this.
In the terms of lets say something cause your SSD to burn out within a year, with a known bug. I feel the company the software bug should be held responsible.
Turns out that you could increase the volume causing hard clipping, which caused physical problems on the speakers.
[1] http://en.community.dell.com/support-forums/laptop/f/3517/t/...
A great testing tool would be to induce latency on seeks or keeps track of writes / fake disk seek sounds to avoid these kinds of problems going undetected during development.
Maybe someone can program a Mac's camera light indicator to blink when the SSD is writing?
People on this forum are reporting that its eating up 50GB's on idle. Could it be possible they are using idle clients to help stream content to other users?
edit: ok, I got the answer by myself: apparently, Vacuum copies the database to a temporary file and then it overwrite the original, it's not the usage, it's the writes that are the problem here.
These work quite well for the user, as it's enjoyable to listen to music on your stereo at home, then just tell the phone app to switch from your stereo to your phone (maybe over headphones) while you're mobile. And heavy use of P2P between devices on the same LAN or Wifi network would reduce internet bandwidth use, but may unintentionally cause a lot of churn and disk use.
Playing a song from a phone 'pushing' to a device on a slow connection always causes troubles for me.
https://techcrunch.com/2014/04/17/spotify-removes-peer-to-pe...
Is spotify shipping an unsigned binary?
Basically, code signing on iOS is dynamically secure, modulo vulnerabilities, and macOS is steadily on its way to become more like iOS in this regard.
* But not fun for security research and having ultimate control of your device. Always the tradeoffs...
http://www.newosxbook.com/articles/CodeSigning.pdf
https://developer.apple.com/library/content/technotes/tn2206...
Finally this is taken to a level where Spotify might actually notice something !
There were/are threads on their forum and basically nothing happens as they seems to not care for the users.
Look what I found with a `cat /proc/$pid/io` on the main spotify process:
rchar: 315169616727
wchar: 236191291851
syscr: 320352243
syscw: 330963886
read_bytes: 945213440
write_bytes: 230711586816
cancelled_write_bytes: 51481772032
That's 230GB written over 6 days of uptime. Granted, some of that is to the network, to an audio device, or just normal download caching. Still...good grief.I had the gut feeling something had been wrong with the Linux client for a while. Spotify also tends to show up pretty high in h/top, aside from iotop.
From other comments, it sounds like it is defragmenting a database file which is normally only a few hundred MB max. However, defragmenting this file means it essentially writes a duplicate of that file, switches over to the new file, and deletes the old one. So, it uses a lot of writes, but its writing the same couple hundred MB over and over again, with the total usage only being 2X the max size of the file, assuming no fragmentation. If there is a lot of fragmentation, that multiplier would be less than 2.
I haven' noticed crazy battery burn on my Nexus 5x, but then I don't actively use Spotify much (meaning I should probably cancel it now that the trial period is over, anyway...)
Todays Spotify desktop client is nothing more than another web browser, which uses WebKit to render all its interface as a web page inside the app window.
Given Chrome's battery and RAM usage, it's not surprising that Spotify performs poorly even compared to iTunes.
Isn't there enough evidence that wrapped web apps like Slack or Atom (and now Spotify) perform worse than the native apps?
Even better, Google Play music seems to support my current country. With Spotify I had to use an old credit card which was from the time I was living in Czech Republic.
Not a spotify user, cannot say this is viable solution.
I'm running 1.0.42.151.g19de0aa6 on Ubuntu and I'm seeing 351 MB written to disk in under 15 minutes without listening to any music at all.
Fuck me.
Note: Spotify will recreate the folder with a normal amount of writes.