Open
Description
Description
When I am using validation rules on items for repeated fields with env variable PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb, validation is extremely slow
Steps to Reproduce
Using the following message:
message RepeatedItems {
repeated int64 items = 1 [
(buf.validate.field).repeated = {
items: {
int64: {gt: 0}
}
}
];
}
Run this code:
import protovalidate
import time
from gen.tests.example.v1 import validations_pb2
msg = validations_pb2.RepeatedItems(items=[i + 1 for i in range(2000)])
start = time.perf_counter()
protovalidate.validate(msg)
end = time.perf_counter()
print(f"Finished one in {end-start:.2f} seconds")
Is executing about:
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb python main.py
Finished one in 2.08 seconds
and with PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python:
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python python main.py
Finished one in 0.01 seconds
But I guess both are pretty slow for just a validation call.
I have tried pre-warming up and doing it in a loop, however, numbers are the same after first call.
Environment
- Operating System: macOS Sequoia
- Compiler/Toolchain: Apple clang version 17.0.0 (clang-1700.0.13.3)
- Protobuf Compiler & Version: buf v1.54.0
- Protovalidate Version: v0.8.0