MBP 13, 2015 with 128 GB SSD and 8 GB RAM.
I have noticed, that after only some 20 GB of SSD was free my Safari browser was very slow.
RAM was used 4-6 GB from 8.
Is it general possible, that SSD can slow the MAC or it was some other reason?
While this is certainly not the only reason you may experiencing a slow down, a filled up SSD is one possible reason for slow downs.
The first reason connected to that is inherent to the filesystem macOS uses. If the filesystem is HFSplus, then the free space usually needs to be above a certain percentage to ensure smooth operation. If the free space falls below 25% things start to get complicated and the directory structure gets more and more inefficient. To name just one reason connected to the filesystem.
Next it depends on whether you have trim enabled or not. Without trim it gets harder and harder to know which cells to use next as the wear leveling is designed to use each cell ideally equally compared to the others. On an original Apple SSD trim should be enabled.
Then all currently sold SSDs age and get indeed slower over time. This should not be that much noticeable, though.
More importantly, all the above combines to something like a perfect storm on all SSDs, as they fill up:
The benchmarks are clear: Solid-state drives slow down as you fill them up. Fill your solid-state drive to near-capacity and its write performance will decrease dramatically. The reason why lies in the way SSDs and NAND Flash storage work.
Filling the drive to capacity is one of the things you should never do with a solid-state drive. A nearly full solid-state drive will have much slower write operations, slowing down your computer.
Empty Blocks and Partially Filled Blocks
When you write a file to your solid-state drive, it looks for empty blocks and fills them. Writing to an empty block is the fastest possible write operation. That’s why new operating systems (Windows 7 and later) support the TRIM feature, which automatically deletes a file’s data from the solid-state drive as soon as you delete the file in your operating system. This works differently from magnetic hard drives, where bits of deleted files sit around on the hard drive.
They don’t sit around on a solid-state drive — TRIM ensures that the block is emptied so the SSD can quickly write new data to the empty block in the future. Writing over an already-written sector is just as fast as writing to an empty sector on a mechnical hard drive, but a solid-state drive must erase a block before writing to it.
NAND Flash memory writes data in 4 KB pages inside of 256 KB blocks. To add additional pages to a partially filled block, the solid-state drive must erase the entire block before writing data back to it.
As your solid-state drive fills up, fewer and fewer empty blocks are available. In their place are partially filled blocks. The solid-state drive can’t just write the new data to these partially filled blocks — that would erase the existing data. Instead of a simple write operation, the solid-state drive has to read the value of the block into its cache, modify the value with the new data, and then write it back. Bear in mind that writing a file will likely involve writing to many blocks, so this can introduce a significant amount of additional delay.
TRIM Doesn’t Consolidate Partially Filled Blocks
If you fill a drive to capacity or near capacity, it’s likely that you’ll end up with many partially filled blocks after you delete files. The TRIM command just directs a solid-state drive to remove file data when the file is deleted. It doesn’t force the drive to do any sort of cleanup operation.
In other words, fill a solid-state drive to capacity before deleting files and you’ll likely end up with many partially filled blocks. The drive won’t go out of its way to consolidate these partially-filled blocks into full blocks, freeing up empty blocks. The drive will still be full of partially filled blocks and write performance will be degraded.
Overprovisioning and Garbage Collection
To prevent consumers from filling up their solid-state drives and ending up with severely degraded performance, SSD manufacturers are going out of their way to counter this.
Consumer-grade solid-state drives often set aside about 7% of their total flash storage and make it unavailable to the user. This is known as “overprovisioning” — extra storage hardware is added to the drive but isn’t visible to the computer as available storage it can use. The spare area ensures that the drive can never become completely full — there will always be some spare capacity to help keep write performance stable.
Each solid-state drive’s controller has a garbage-collection algorithm to try to mitigate this problem. When the drive becomes full, it will look for partially-filled blocks and start to consolidate them, freeing up as many empty blocks as possible. Different solid-state drives run these operations at different times and thresholds — that depends on the drive’s controller.
Anandtech performed a variety of benchmarks with different drives to tease out the relationship between a solid-state drive’s spare area and the consistency of its write operation performance. When filling up an empty drive, they found high write performance very early in the process and a significant drop as the write operations continued to fill up the drive.
Setting aside more spare area on the drives helped the performance to remain consistent, as it ensured the drive should always have enough empty blocks ready.
They found that “minimum performance improves substantially once you hit 25% spare area for these [consumer] drives.” Their final recommendation was that you should “plan on using only about 75% of [your drive’s] capacity if you want a good balance between performance consistency and capacity.”
If you have a solid-state drive, you should try to avoid using more than 75% of its capacity. Buy a larger drive with more storage than you need and you’ll ensure that you always have consistent write performance. Luckily, SSDs are gradually becoming much cheaper, so this isn’t as expensive as it once was.
Apart from these general considerations, if the perceived slow downs are exclusive to the browser, then the browser itself is the more likely culprit.
Using the same amount of free space on the SSD but with a fresh browser profile, and a freshly launched browser, things will likely look much better in most cases.
An easy test for this might be creating a new user, log into that and try it out. If things look better, it's time to cleanup your browser profile. Caches, cookies, icons, local storage, extensions, the lot…