code: def _validate_schema(schema, body):
      
  
      # Note
      #
      # Schema validation is currently the major CPU bottleneck of
      # BigchainDB. the `jsonschema` library validates python data structures
      # directly and produces nice error messages, but validation takes 4+ ms
      # per transaction which is pretty slow. The rapidjson library validates
      # much faster at 1.5ms, however it produces _very_ poor error messages.
      # For this reason we use both, rapidjson as an optimistic pathway and
      # jsonschema as a fallback in case there is a failure, so we can produce
      # a helpful error message.
  
      try:
          schema[1](rapidjson.dumps(body))
      except ValueError as exc:
          try:
              jsonschema.validate(body, schema[0])
          except jsonschema.ValidationError as exc2:
              raise SchemaValidationError(str(exc2)) from exc2
          logger.warning('code problem: jsonschema did not raise an exception, wheras rapidjson raised %s', exc)
          raise SchemaValidationError(str(exc)) from exc
docs: Validate data against a schema