perf(jans-cedarling): optimize string types, logging path and entity serialization by dagregi · Pull Request #14090 · JanssenProject/jans (original) (raw)
📝 Walkthrough
Walkthrough
This PR optimizes the Cedarling logging system by implementing string interning with Arc<str> and SmolStr, simplifying entity serialization to a single-pass conversion, deferring expensive log entry construction via lazy evaluation, and narrowing critical sections in the memory logger.
Changes
Performance and memory optimization for logging system
| Layer / File(s) | Summary |
|---|---|
| ApplicationName refactoring to Arc src/common/app_types.rs, src/lib.rs, src/lock/health_ticker.rs | ApplicationName backing type is changed from String to Arc with manual serde impls. Callers use From conversion; health_ticker converts to String for compatibility where needed. |
| PolicyInfo refactoring to SmolStr src/log/log_entry.rs | PolicyInfo id and description fields change to SmolStr. Diagnostics::new converts policy IDs and descriptions to SmolStr during construction to intern repeated values. |
| Single-pass entity JSON serialization src/authz/mod.rs | Removes Cursor-based buffer round-trip (write_to_json + from_slice) and replaces with direct to_json_value conversion for one-pass serialization. |
| Lazy DecisionLogEntry with would_log early-exit src/log/log_strategy.rs | Adds would_log helper to short-circuit expensive log entry construction when log levels are disabled. log_fn and LogWriter::log_any early-return on false, avoiding allocation and dispatch. |
| MemoryLogger mutex scope narrowing src/log/memory_logger/mod.rs | Refactors log_entry to scope mutex lock only during storage set/evict/retry, releasing before error handling. StrWrap changes from tuple to named-field struct. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested labels
kind-enhancement, comp-jans-cedarling
Suggested reviewers
- olehbozhok
- tareknaser
- haileyesus2433 🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Linked Issues check | ❓ Inconclusive | The PR partially addresses linked issue #14032 objectives: implements Arc string interning, single-pass entity serialization, and early logging checks; however, OnceLock for lock_service, per-thread ring buffers for MemoryLogger, and lazy DecisionLogEntry construction appear incomplete or not fully realized. | Verify whether lock_service replacement with OnceLock and per-thread ring buffer MemoryLogger changes are present but not captured in the summary, or confirm these remain as future work separate from this PR scope. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title accurately summarizes the main changes: optimization of string types (Arc for ApplicationName and PolicyInfo ids), logging path (early "would_log" check), and entity serialization (single-pass to_json_value instead of two-step process). |
| Description check | ✅ Passed | The description covers the required sections: Read PR and license guidelines (checked), Target issue linked (#14032), Implementation Details mostly provided, static analysis run, but missing specific details on testing and documentation claims. |
| Out of Scope Changes check | ✅ Passed | All changes are directly aligned with #14032 objectives: string type optimizations, entity serialization improvements, and logging path enhancements. No unrelated modifications detected in the provided file summaries. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 88.24% which is sufficient. The required threshold is 80.00%. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches 📝 Generate docstrings
- Create stacked PR
- Commit on current branch 🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
jans-cedarling-14032
Tip
💬 Introducing Slack Agent: The best way for teams to turn conversations into code.
Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
- Generate code and open pull requests
- Plan features and break down work
- Investigate incidents and troubleshoot customer tickets together
- Automate recurring tasks and respond to alerts with triggers
- Summarize progress and report instantly
Built for teams:
- Shared memory across your entire org—no repeating context
- Per-thread sandboxes to safely plan and execute work
- Governance built-in—scoped access, auditability, and budget controls
One agent for your entire SDLC. Right inside Slack.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment @coderabbitai help to get the list of available commands and usage tips.