You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I am using validation rules on items for repeated fields with env variable PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb, validation is extremely slow
importprotovalidateimporttimefromgen.tests.example.v1importvalidations_pb2msg=validations_pb2.RepeatedItems(items=[i+1foriinrange(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
The text was updated successfully, but these errors were encountered:
buf.gen.yaml (if not using Buf, show protoc command for generating code)
I was able to recreate this on my machine (Apple M1). However, I'm not seeing the 0.01s result for using the python backend. I actually see comparable (albeit slow) results for both:
$ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=upb python3 main.py
Finished one in 3.83 seconds
$ PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python python3 main.py
Finished one in 3.92 second
Definitely something we should take a look at, but want to gather all the information first.
I have provided an example with slow validation by generating it in this pull request, so, I guess buf.gen.yaml is the same as in main branch of the current repository
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:
Run this code:
Is executing about:
and with PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python:
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
The text was updated successfully, but these errors were encountered: