From 915027f60745a9765af46e75a04e62814c865e2f Mon Sep 17 00:00:00 2001 From: Wojciech Sromek <157375010+wojciechsromek@users.noreply.github.com> Date: Tue, 14 Jan 2025 18:04:17 +0100 Subject: [PATCH] doc: Provide ADR for load performance optimisation (#936) --- adr/002-load-performance-optimisation.md | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 adr/002-load-performance-optimisation.md diff --git a/adr/002-load-performance-optimisation.md b/adr/002-load-performance-optimisation.md new file mode 100644 index 000000000..f25e83354 --- /dev/null +++ b/adr/002-load-performance-optimisation.md @@ -0,0 +1,31 @@ +# ADR-002: Load Performance Optimisation + +### Links +[Notion Page on the boot optimisation](https://www.notion.so/worldcoin/SMPCv2-Boot-time-optimisation-1458614bdf8c80c39170dc0040eb9acf) + +## Context +- on every boot-up the container needs to load a couple of 100s of GBs (and the number is constantly growing, hopefully into TBs) +- the load is performed directly from the AuroraDB +- we need to be able to boot the container below 10 minutes + +## Decision +We have decided to prepare an `iris-mpc-db-exporter` service that is going to be periodically storing a dump of the database in an S3 bucket. The loading of the data from the bucket, based on our research are going to be significantly faster than from the AuroraDB. + +Aiming to boost the performance further we have decided to move the conversion of `u8` into `i8` to the exporting service. + +**What was also implemented there was a modification of the order of the bytes for the sake of faster loading into the memory of `iris-mpc` pods.** + +## Rationale +- The loading of the data from the S3 bucket is significantly faster than from the AuroraDB. +- The conversion of `u8` into `i8` is a simple operation that can be done in the exporting service. +- The modification of the order of the bytes is a simple operation that can be done in the exporting service. + +## Consequences +Because of the actions required to make the loading of the data more efficient (altered byte order, byte values shifted) right now we have two storages: +- AuroraDB (source of truth) +- S3 bucket (used for improving the data load time) + +They both store the same data **but in different formats**, please refer to implementation (references are accurate in revision `ec14a0c022b73d2d291578502f6bf02cbc0a99d0`): +- `iris-mpc-store/src/lib.rs:41` (universal type for both data formats) +- `iris-mpc-gpu/src/server/actor.rs:464` (method for loading data from AuroraDB into memory) +- `iris-mpc-gpu/src/server/actor.rs:503` (method for loading data from S3 bucket into memory)