Repository navigation
AddParam(value) and AddParams(object) allocate no more on a repeat call than AddParam("@name", value) - #104
Merged
Merged
Conversation
…named ones The procedure's names and what each argument matched are remembered in one set, the cache key is a struct instead of a string, and the unique-name resolution no longer copies the parameter list. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…be derived, and a text command's collision when the names are not known Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…mber test Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
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.
A user measured
AddParams(object)with three members at about 2.1 KB more per call than three namedAddParamcalls. The procedure's names were already remembered, but the matching was redone on every execution.What was redone on every call
List<Param>copies of the parameters.@, for each argument.@name in the two same-name loops.What is cached now, where, and for how long
NameSetholds a procedure's real names, the names without@(once), and the name each argument expression matched. It lives as long as the procedure's entry: 5 minutes, then it is read again. A match that throws (an ambiguity) is not stored, so it throws on every call. Limits and the weak owner are unchanged.NameSetis kept on the command text string (aConditionalWeakTable, nostring.IsInternedgate): a literal stays cached, a released string's entry goes with it.AddParam(value)no longer creates the options block.Param.ValueandDbParameter.Valueareobject, so the namedAddParamboxes as well.Bytes per call (in-memory fakes, after warm-up)
AddParamswith 3 membersAddParamsThe named side went from 552 to 560 bytes because of the command size (below). The new test file asserts derived <= named + 16 for each case except the dynamic-SQL one.
Command size:
conn.Command(sql)allocates 56 bytes before and 64 after (the flag field adds 8). The saving is far larger, so the change stays.SQL built on every call
When the SQL text is a new string object each time, its entry is used only while that string lives. It costs 1720 bytes per call (about 920 more than the named call), plus a GC handle that the allocated bytes do not show. That trade is accepted: memory for speed, and the weak table cannot grow out of control because each entry goes with its string. A string built once and reused, or reused before it is collected, is a hit. There is no
string.IsInternedgate, by decision.Notes
DataSourceandDatabaseof a real provider may allocate; the fakes return constants, so that is not measured.PublicAPI.*.txtare untouched.Checks
AddParamsmember whose name cannot be derived (a verbatim@default) throwsArgumentExceptionon every call, and a text command's collision message when the names are not known is pinned.🤖 Generated with Claude Code