Companies can be real vicious when it comes to downsizing or whatever name they give the retrenchment of workers. While I haven't ever personally been affected by this, I certainly know more than a few people who have with various forms of testimonies to share. In summary, it certainly isn't a pleasant experience but it is one that sometimes may be outside our control.
Of course there are several grounds for a termination of appointment, and some of them are of our own making. Pure incompetence and underperformance should never be excused. Yet there are times when a company simply feels they need to make certain cuts to stay afloat, make more money by reducing their overhead cost or provide space for new entrants. In those instances those affected can't help but feel a certain way by decisions taken against them.
I have had conversations with friends in other sectors and a few acquaintances who have been laid off in the past, on how exactly one can best prepare for a surprise layoff. The unsurprising answer for most is that there is no definitive way to make such preparations, and it hurts to be laid off irrespective of how prepared we may be. Yet there are actions that could potentially carry us through those times should they ever happen.
I don't wish to be laid off but I believe that the first step to overcoming any obstacle is facing it head on. In this context this means acknowledging that such situations can happen regardless of output and effort. With that knowledge I've been taking little time, effort and resources to build suitable buffers should I ever need them.