1) There is a "filter" problem, eg bias in interviewing. This is what you are talking about.
2) There is the "pipeline" problem, eg universities and recruiting practices.
3) There is the self-selection problem, eg women / minorities going into other fields because they don't want to deal with the horseshit.
...plus many others, including how the few women are treated after they get the job.
The only cure is sunlight. You optimize what you measure. If we can get tech companies to publish these numbers every year, then maybe they'll start doing something about it.