SAS Viya Programming Guide

Stress Test & Benchmarking SAS Viya: Efficiently saturating your CAS CPU cores

Simon 23/12/2025 45 views

Introduction

During the deployment or maintenance of a SAS© Viya environment, one question consistently arises: "Can the infrastructure handle the load?"

Tests are often limited to loading large CSV files (disk I/O testing) or running complex models on small tables. However, to truly stress-test the computing power (CPU) and distributed memory management of CAS (Cloud Analytic Services) nodes, a different approach is required.

This article outlines a "Pure Code" methodology to generate a massive stress test—free of external file dependencies and executed entirely within RAM.

Illustration

The Methodology

Our approach relies on three technical pillars to guarantee that the test stresses the infrastructure rather than the disk storage.

1. The In-Memory "Data Factory" (In-Memory Generation)

Instead of loading terabytes of data from a disk (which would test network/storage bandwidth), we use the CAS engine to generate the data.

  • Technique: Use of the data / single=no statement.

  • Effect: The code executes in parallel on all CAS workers. Every available CPU core is used to manufacture data rows.

  • Volume: Starting from the small sashelp.cars table, we apply a multiplication factor (e.g., x100,000) to instantly reach tens of millions of rows.

2. ALU and FPU Saturation (CPU Stress)

Merely moving data isn't enough to heat up the processors; they need to be fed complex calculations.

  • Technique: Injection of transcendental mathematical functions (SIN, COS, TAN, EXP, LOG) and random number generation (RAND).

  • Effect: These operations force the processor's Floating Point Unit (FPU) to work at 100%, simulating Machine Learning or complex Scoring workloads.

3. Network "Shuffle" and Aggregation

Once the data is created, the cluster's communication capacity must be tested.

  • Technique: Use of PROC MDSUMMARY with a GROUP BY on multiple variables.

  • Effect: To group the data, CAS must redistribute rows between the different nodes (Shuffling). This tests inter-node latency and memory bandwidth, while continuing to consume CPU for statistical calculations (Mean, Standard Deviation).

4. Integrated Metrology

The code includes a system of macros (%tick / %tock) that captures the exact execution time of each step and generates an automatic final report.


The Complete Code

Below is the complete program. It is standalone (requiring no external data other than sashelp) and can be copied and pasted directly into SAS© Studio.

1/******************************************************************************
2 * STRESS TEST SAS VIYA (CAS) AVEC RAPPORT DE PERFORMANCE
3 ******************************************************************************/
4 
5/* --- BLOC INITIALISATION DU CHRONO --- */
6/* On crée une table vide pour stocker les résultats */
7DATA work.time_log;
8 LENGTH Etape $50;
9 Start_Time = .;
10 End_Time = .;
11 Duration = .;
12 FORMAT Start_Time End_Time datetime20. Duration time13.2;
13 stop;
14RUN;
15 
16/* Variable globale pour stocker le temps de départ */
17%global start_tick;
18 
19/* Macro pour démarrer le chrono */
20%macro tick;
21 %let start_tick = %sysfunc(datetime());
22%mend;
23 
24/* Macro pour arrêter le chrono et enregistrer l'étape */
25%macro tock(step_name);
26 DATA _null_;
27 start = &start_tick;
28 END = datetime();
29 duration = END - start;
30
31 /* Insertion dans la table de log */
32 call execute("data work.temp_log;");
33 call execute("Etape = '&step_name';");
34 call execute("Start_Time = " || start || ";");
35 call execute("End_Time = " || END || ";");
36 call execute("Duration = " || duration || ";");
37 call execute("format Start_Time End_Time datetime20. Duration time13.2;");
38 call execute("run;");
39
40 call execute("proc append base=work.time_log data=work.temp_log force; run;");
41 call execute("proc delete data=work.temp_log; run;");
42 RUN;
43%mend;
44 
45/* --- DEBUT DU PROGRAMME UTILISATEUR --- */
46 
47/* 1. Démarrage de la session CAS */
48%tick; /* Démarrage chrono */
49cas mySession sessopts=(caslib=casuser timeout=3600 locale="fr_FR");
50LIBNAME mycas cas caslib=casuser;
51%tock(1. Connexion CAS); /* Fin chrono étape 1 */
52 
53 
54/* 2. Création du jeu de données "Big Data" en mémoire */
55%let duplication_factor = 100000;
56 
57%tick; /* Démarrage chrono */
58DATA mycas.big_data_stress / single=no;
59 SET sashelp.cars;
60
61 /* On duplique chaque ligne N fois */
62 DO i = 1 to &duplication_factor.;
63
64 unique_id = catx('_', make, model, i, _n_);
65
66 /* SECTION STRESS CPU */
67 u1 = rand('Uniform');
68 u2 = rand('Normal', 50, 10);
69
70 stress_val1 = sin(invoice) * cos(msrp) + log(abs(weight)+1);
71 stress_val2 = exp(u1) * sqrt(invoice) / (tan(u1) + 2);
72
73 OUTPUT;
74 END;
75
76 keep make model type origin invoice msrp unique_id stress_val1 stress_val2;
77RUN;
78%tock(2. Generation DATA (x&duplication_factor)); /* Fin chrono étape 2 */
79 
80 
81/* Vérification taille (CASUTIL) */
82%tick;
83PROC CASUTIL;
84 contents casdata="big_data_stress";
85RUN;
86%tock(3. CASUTIL Contents);
87 
88 
89/* 3. Application de la procédure pour "Stresser" le CPU */
90%tick;
91PROC MDSUMMARY DATA=mycas.big_data_stress;
92 groupby make origin type;
93 var stress_val1 stress_val2 invoice msrp;
94 OUTPUT out=mycas.summary_results;
95RUN;
96%tock(4. MDSUMMARY Stress Test);
97 
98 
99/* --- RAPPORT FINAL --- */
100title "Rapport de Performance - Stress Test CAS";
101PROC PRINT DATA=work.time_log noobs;
102 var Etape Start_Time End_Time Duration;
103 sum Duration; /* Affiche le temps total en bas */
104RUN;
105title;
106 
107/* Fin de la session */
108cas mySession terminate;