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.
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.
/******************************************************************************
* STRESS TEST SAS VIYA (CAS) AVEC RAPPORT DE PERFORMANCE
******************************************************************************/
/* --- BLOC INITIALISATION DU CHRONO --- */
/* On crée une table vide pour stocker les résultats */
data work.time_log;
length Etape $50;
Start_Time = .;
End_Time = .;
Duration = .;
format Start_Time End_Time datetime20. Duration time13.2;
stop;
run;
/* Variable globale pour stocker le temps de départ */
%global start_tick;
/* Macro pour démarrer le chrono */
%macro tick;
%let start_tick = %sysfunc(datetime());
%mend;
/* Macro pour arrêter le chrono et enregistrer l'étape */
%macro tock(step_name);
data _null_;
start = &start_tick;
end = datetime();
duration = end - start;
/* Insertion dans la table de log */
call execute("data work.temp_log;");
call execute("Etape = '&step_name';");
call execute("Start_Time = " || start || ";");
call execute("End_Time = " || end || ";");
call execute("Duration = " || duration || ";");
call execute("format Start_Time End_Time datetime20. Duration time13.2;");
call execute("run;");
call execute("proc append base=work.time_log data=work.temp_log force; run;");
call execute("proc delete data=work.temp_log; run;");
run;
%mend;
/* --- DEBUT DU PROGRAMME UTILISATEUR --- */
/* 1. Démarrage de la session CAS */
%tick; /* Démarrage chrono */
cas mySession sessopts=(caslib=casuser timeout=3600 locale="fr_FR");
libname mycas cas caslib=casuser;
%tock(1. Connexion CAS); /* Fin chrono étape 1 */
/* 2. Création du jeu de données "Big Data" en mémoire */
%let duplication_factor = 100000;
%tick; /* Démarrage chrono */
data mycas.big_data_stress / single=no;
set sashelp.cars;
/* On duplique chaque ligne N fois */
do i = 1 to &duplication_factor.;
unique_id = catx('_', make, model, i, _n_);
/* SECTION STRESS CPU */
u1 = rand('Uniform');
u2 = rand('Normal', 50, 10);
stress_val1 = sin(invoice) * cos(msrp) + log(abs(weight)+1);
stress_val2 = exp(u1) * sqrt(invoice) / (tan(u1) + 2);
output;
end;
keep make model type origin invoice msrp unique_id stress_val1 stress_val2;
run;
%tock(2. Generation Data (x&duplication_factor)); /* Fin chrono étape 2 */
/* Vérification taille (CASUTIL) */
%tick;
proc casutil;
contents casdata="big_data_stress";
run;
%tock(3. CASUTIL Contents);
/* 3. Application de la procédure pour "Stresser" le CPU */
%tick;
PROC MDSUMMARY DATA=mycas.big_data_stress;
groupby make origin type;
var stress_val1 stress_val2 invoice msrp;
OUTPUT out=mycas.summary_results;
RUN;
%tock(4. MDSUMMARY Stress Test);
/* --- RAPPORT FINAL --- */
title "Rapport de Performance - Stress Test CAS";
proc print data=work.time_log noobs;
var Etape Start_Time End_Time Duration;
sum Duration; /* Affiche le temps total en bas */
run;
title;
/* Fin de la session */
cas mySession terminate;
keep make model type origin invoice msrp unique_id stress_val1 stress_val2;
77
RUN;
78
%tock(2. Generation DATA (x&duplication_factor)); /* Fin chrono étape 2 */
79
80
81
/* Vérification taille (CASUTIL) */
82
%tick;
83
PROC CASUTIL;
84
contents casdata="big_data_stress";
85
RUN;
86
%tock(3. CASUTIL Contents);
87
88
89
/* 3. Application de la procédure pour "Stresser" le CPU */
90
%tick;
91
PROC MDSUMMARYDATA=mycas.big_data_stress;
92
groupby make origin type;
93
var stress_val1 stress_val2 invoice msrp;
94
OUTPUT out=mycas.summary_results;
95
RUN;
96
%tock(4. MDSUMMARY Stress Test);
97
98
99
/* --- RAPPORT FINAL --- */
100
title "Rapport de Performance - Stress Test CAS";
101
PROC PRINTDATA=work.time_log noobs;
102
var Etape Start_Time End_Time Duration;
103
sum Duration; /* Affiche le temps total en bas */
104
RUN;
105
title;
106
107
/* Fin de la session */
108
cas mySession terminate;
Important Disclaimer
The codes and examples provided on WeAreCAS.eu are for educational purposes. It is imperative not to blindly copy-paste them into your production environments. The best approach is to understand the logic before applying it. We strongly recommend testing these scripts in a test environment (Sandbox/Dev). WeAreCAS accepts no responsibility for any impact or data loss on your systems.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.