cripts: shrink Context from 3408 to 1920 bytes, expand data[] to 16#13195
Open
zwoop wants to merge 2 commits into
Open
cripts: shrink Context from 3408 to 1920 bytes, expand data[] to 16#13195zwoop wants to merge 2 commits into
zwoop wants to merge 2 commits into
Conversation
Pimpl Url::Path and Url::Query state behind unique_ptr so the heavy vector/unordered_map/cripts::string members only allocate when a script actually decomposes the path or query. Lazy-allocate Pristine, Parent, and Remap From/To URLs in _UrlBlock — they're rarely all touched, and the embedded 384-byte Url objects dominated the per-txn cost. Pimpl Error::Reason for the same reason. Drop the unused INET6_ADDRSTRLEN buffer in detail::ConnBase. Make cripts::Url's destructor virtual now that we delete via unique_ptr. Bump CONTEXT_DATA_SLOTS from 4 to 16 so scripts have room to stash more per-txn state — the 384-byte cost sits inside the budget freed by the URL/Connection cuts.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces per-transaction cripts::Context footprint by lazily allocating heavier URL/query/path/error state only when accessed, and expands the per-txn Context::data[] slots to allow scripts to stash more state.
Changes:
- PIMPL/lazy-allocate
Url::PathandUrl::Queryinternal state (segments/unordered_map/ storage) and make their assignment operators return references. - Lazy-allocate rarely-used URL objects in
Context(Pristine,Parent,Remap From/To) andError::Reasonviastd::unique_ptr. - Increase
CONTEXT_DATA_SLOTSto 16 and remove an unusedINET6_ADDRSTRLENbuffer fromdetail::ConnBase.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/cripts/Urls.cc | Implements lazy URL slot allocation and moves path/query segment/param storage behind per-component state. |
| src/cripts/Error.cc | Lazily allocates Error::_reason when setting a reason message. |
| src/cripts/Context.cc | Resets lazy URL slots by releasing unique_ptrs between transactions. |
| include/cripts/Urls.hpp | Introduces State pimpls for Path/Query, updates APIs, and makes Url destructor virtual. |
| include/cripts/Error.hpp | Switches Error::_reason to std::unique_ptr<Reason>. |
| include/cripts/Context.hpp | Expands Context::data[] slots and changes URL block members to unique_ptr for lazy creation. |
| include/cripts/Connections.hpp | Removes an unused string buffer from detail::ConnBase. |
Bounds-check Path::Erase to avoid dereferencing a null _owner when
ix is out of range — operator[] returns a default-constructed String
in that case, and the subsequent p.operator=("") would then crash
inside String::operator=.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pimpl
Url::PathandUrl::Querystate behindunique_ptrso the heavy vector/unordered_map/cripts::stringmembers only allocate when a script actually decomposes the path or query. Lazy-allocate Pristine, Parent, and Remap From/To URLs in _UrlBlock — they're rarely all touched, and the embedded 384-byte Url objects dominated the per-txn cost. Pimpl Error::Reason for the same reason. Drop the unused INET6_ADDRSTRLEN buffer in detail::ConnBase. Make cripts::Url's destructor virtual now that we delete via unique_ptr. Bump CONTEXT_DATA_SLOTS from 4 to 16 so scripts have room to stash more per-txn state — the 384-byte cost sits inside the budget freed by the URL/Connection cuts.