Skip to content

Conversation

MarcBridner
Copy link
Contributor

Description of changes

Adds stateful_is_authorized, preparse_policy_set and preparse_schema that can be used to pre-load an immutable schema/policy set.

This way, we don't have to build a massive JSON struct on each authorization request.

In our tests where we perform approximately 50000 evaluations the execution time went from:

real    13m33.222s
user    132m49.959s
sys     1m43.130s

to

real    0m52.297s
user    7m55.203s
sys     1m8.939s

Or, in other words, a 15x performance increase.

Issue #, if available

#1829

Checklist for requesting a review

The change in this PR is (choose one, and delete the other options):

  • A backwards-compatible change requiring a minor version bump to cedar-policy (e.g., addition of a new API).

I confirm that this PR (choose one, and delete the other options):

  • Updates the "Unreleased" section of the CHANGELOG with a description of my change (required for major/minor version bumps).

I confirm that cedar-spec (choose one, and delete the other options):

  • Does not require updates because my change does not impact the Cedar formal model or DRT infrastructure.

I confirm that docs.cedarpolicy.com (choose one, and delete the other options):

  • Does not require updates because my change does not impact the Cedar language specification.

Copy link
Contributor

@chaluli chaluli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a good thing if it's 15x speedup.

Please update the CHANGELOG to specify that this is a change in the FFI/wasm. Also, fix the formatting issues.

@MarcBridner MarcBridner force-pushed the main branch 2 times, most recently from 70d0c06 to 2a81e21 Compare September 18, 2025 19:55
Copy link
Contributor

@chaluli chaluli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good once CI passes.

}
}

impl StatefulAuthorizationCall {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, AuthorizationCall and PartialAuthorizationCall are substantial similar. Wondering if there's any parsing logic we can share

Copy link
Contributor Author

@MarcBridner MarcBridner Sep 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went for the "rather have some duplication than break something existing" approach for this PR.
I'm not very familiar with the idiosyncrasies of Rust so I figured this'd be safer. I can give it a try if required.

@MarcBridner MarcBridner force-pushed the main branch 2 times, most recently from 6a84478 to 54b1b20 Compare September 19, 2025 04:22
Copy link

Coverage Report

Head Commit: b8182da4fdc633656aa8925da2d105d694f76c88

Base Commit: cbbb8459a16d9d3725facfa46b214c88fab4484c

Download the full coverage report.

Coverage of Added or Modified Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 91.09%

Status: PASSED ✅

Details
File Status Covered Coverage Missed Lines
cedar-policy/src/ffi/is_authorized.rs 🟢 92/101 91.09% 744-746, 749-750, 795-796, 804, 819

Coverage of All Lines of Rust Code

Required coverage: 80.00%

Actual coverage: 84.04%

Status: PASSED ✅

Details
Package Status Covered Coverage Base Coverage
cedar-language-server 🟢 4619/5120 90.21% 90.21%
cedar-policy 🟡 3513/4943 71.07% 70.65%
cedar-policy-cli 🔴 675/1054 64.04% 64.04%
cedar-policy-core 🟢 21422/25181 85.07% 85.03%
cedar-policy-formatter 🟢 930/1112 83.63% 83.63%
cedar-policy-symcc 🟢 4715/5249 89.83% 89.83%
cedar-wasm 🔴 0/28 0.00% 0.00%

@john-h-kastner-aws
Copy link
Contributor

Looks good. Merging!

@john-h-kastner-aws john-h-kastner-aws merged commit e25a927 into cedar-policy:main Sep 22, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants