Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Freeze some collections for faster accessing #2023

Closed
wants to merge 8 commits into from

Conversation

ike709
Copy link
Collaborator

@ike709 ike709 commented Oct 7, 2024

Converts some collections on DreamObjectTree and DreamObjectDefinition to their frozen variants. On my machine this consistently reduced Paradise round init by roughly ~2 seconds. I only compared third and fourth runs for both before & after so PGO wouldn't impact the results.

Since these collections never change after JSON parsing, it's a free performance boost on any accesses for the remainder of the round.

I'll try to tackle Procs & Variables in a subsequent PR since they need a bit more wrangling.

@boring-cyborg boring-cyborg bot added the Runtime Involves the OpenDream server/runtime label Oct 7, 2024
@github-actions github-actions bot added the size/L label Oct 7, 2024
@ike709 ike709 requested a review from wixoaGit October 7, 2024 21:38
@@ -454,14 +470,14 @@

internal void SetGlobalNativeProc(NativeProc.HandlerFn func) {
var (name, defaultArgumentValues, argumentNames) = NativeProc.GetNativeInfo(func);
var proc = new NativeProc(_globalProcIds[name], Root, name, argumentNames, defaultArgumentValues, func, _dreamManager, _atomManager, _dreamMapManager, _dreamResourceManager, _walkManager, this);
var proc = new NativeProc(_globalProcIds![name], Root, name, argumentNames, defaultArgumentValues, func, _dreamManager, _atomManager, _dreamMapManager, _dreamResourceManager, _walkManager, this);

Check warning

Code scanning / InspectCode

Redundant nullable warning suppression expression Warning

The nullable warning suppression expression is redundant
@@ -454,14 +470,14 @@

internal void SetGlobalNativeProc(NativeProc.HandlerFn func) {
var (name, defaultArgumentValues, argumentNames) = NativeProc.GetNativeInfo(func);
var proc = new NativeProc(_globalProcIds[name], Root, name, argumentNames, defaultArgumentValues, func, _dreamManager, _atomManager, _dreamMapManager, _dreamResourceManager, _walkManager, this);
var proc = new NativeProc(_globalProcIds![name], Root, name, argumentNames, defaultArgumentValues, func, _dreamManager, _atomManager, _dreamMapManager, _dreamResourceManager, _walkManager, this);

Check warning

Code scanning / InspectCode

Possible null reference argument for a parameter. Warning

Possible null reference argument for parameter 'defaultArgumentValues' in 'OpenDreamRuntime.Procs.NativeProc.NativeProc'

Procs[proc.Id] = proc;
}

public void SetGlobalNativeProc(Func<AsyncNativeProc.State, Task<DreamValue>> func) {
var (name, defaultArgumentValues, argumentNames) = NativeProc.GetNativeInfo(func);
var proc = new AsyncNativeProc(_globalProcIds[name], Root, name, argumentNames, defaultArgumentValues, func);
var proc = new AsyncNativeProc(_globalProcIds![name], Root, name, argumentNames, defaultArgumentValues, func);

Check warning

Code scanning / InspectCode

Redundant nullable warning suppression expression Warning

The nullable warning suppression expression is redundant

Procs[proc.Id] = proc;
}

public void SetGlobalNativeProc(Func<AsyncNativeProc.State, Task<DreamValue>> func) {
var (name, defaultArgumentValues, argumentNames) = NativeProc.GetNativeInfo(func);
var proc = new AsyncNativeProc(_globalProcIds[name], Root, name, argumentNames, defaultArgumentValues, func);
var proc = new AsyncNativeProc(_globalProcIds![name], Root, name, argumentNames, defaultArgumentValues, func);

Check warning

Code scanning / InspectCode

Possible null reference argument for a parameter. Warning

Possible null reference argument for parameter 'defaultArgumentValues' in 'OpenDreamRuntime.Procs.AsyncNativeProc.AsyncNativeProc'
@ike709 ike709 marked this pull request as draft October 8, 2024 03:31
@ike709
Copy link
Collaborator Author

ike709 commented Oct 15, 2024

Superseded by #2031

@ike709 ike709 closed this Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Runtime Involves the OpenDream server/runtime size/L
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant