The sealing between rotating components and stator components has become one of the main issues to be studied in the compressor. The mixing of stator root leakage flow and the mainstream can seriously affect the performance of the compressor. This article does a series of work on numerical calculation of plane diffuser cascade with the stator cavity and three-stage labyrinth seal. It also analyzes the details of the flow structure on upstream cavity. In this paper, the 3D streamlines distribution of the cascade corner region is studied, respectively for the no leakage case and the mixing mechanism of the secondary flow and mainstream with leakage. On this basis, the upstream cavity configuration is optimized and some results are obtained as fellows. The mainstream in the blade leading edge into the upstream cavity comes into being the secondary flow, which similar to leakage flow. It can affect the highest 80% leaves of the high range. Leakage flow is mainly influence on the performance of the blade root flow field and weakly of next to casing area. Compared to no leakage case, angular separation position ahead of time and range increased when there is leakage. Thus, added rib on both sides of the vessel wall can reduce the total pressure loss of the S3 section, and the relative position of ribbed effect significantly. The research shows that first layer of rib is better when set on the hub wall surface, the total pressure loss coefficient decreased by 3.49%.