Skip to content

Profiling support (like --profile) for validate #847

Description

@channi23

Hi, I am Hari!

While understanding Blaze and experimenting with the validation performance of the JSON Schema CLI (as it is built upon Blaze), I was using --benchmark to compare different schemas and understand how the validation cost changes as more keywords and structures are introduced.

The benchmark is useful for telling me how much time the complete validation takes, but it does not tell me what part of the validation is responsible for that time. So I had to create many small schemas and instances to isolate individual pieces of functionality and measure the difference between them.

Because of this, I thought we could have the CLI provide an option like:

jsonschema validate schema.json instance.json --profile

The idea would not necessarily be to implement a profiler inside the CLI. Instead, the option could provide a profiling-friendly execution path that works with external profilers such as Instruments on macOS or perf on Linux.

Conceptually, the distinction I’m thinking about is:

  • --benchmark → How long does validation take?
  • --trace → What validation instructions are being executed?
  • --profile → Where is the execution time being spent?

I noticed that Blaze already has contrib/validate.cc, which appears to provide a convenient way to run validation under an external profiler. So I’m wondering whether exposing a similar workflow through the CLI would be useful.

Also, I’m doing considerably more research into profiling than was probably necessary for this issue. So, if anyone is reading this and thinking about implementing it immediately, please don’t. It will make me sad.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions