X-ray critical dimension (XCD) metrology is a highly promising technique for achieving sub-nanometer precision in critical dimension measurements at advanced nodes of integrated circuit manufacturing. Compared to XCD experiments utilizing synchrotron radiation sources, those employing compact X-ray sources encounter challenges like extended testing time and increased uncertainty. To evaluate the influence of experimental conditions on measurement results, we developed an ab initio virtual X-ray critical dimension metrology via a Monte Carlo simulation (MC-VXCD). Through calibrating the system parameters of the MC-VXCD to a home-built compact XCD instrument, we achieved excellent consistency between virtual and actual measurement results. The virtual instrument effectively estimated measurement errors stemming from the reduced exposure time, which significantly influences the measurement accuracy and throughput. Furthermore, through the MC-VXCD, we establish the connection between the application scenarios of the XCD metrology and the geometry of XCD instruments, offering a versatile platform for the system design, experimental configuration optimization, data analysis, etc., in XCD metrology.