-
Notifications
You must be signed in to change notification settings - Fork 34
chore: upgrade ixgo to v0.59.1 and add SSA prebuild optimization #1019
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
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -121,9 +121,10 @@ var defaultRunner *SpxRunner = NewSpxRunner() | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // SpxRunner encapsulates the build and run functionality for SPX code. | ||||||||||||||||||||||||||||||||||||||
| type SpxRunner struct { | ||||||||||||||||||||||||||||||||||||||
| ctx *ixgo.Context | ||||||||||||||||||||||||||||||||||||||
| entry *interpCacheEntry | ||||||||||||||||||||||||||||||||||||||
| debug bool | ||||||||||||||||||||||||||||||||||||||
| ctx *ixgo.Context | ||||||||||||||||||||||||||||||||||||||
| buildCtx *xgobuild.Context | ||||||||||||||||||||||||||||||||||||||
| entry *interpCacheEntry | ||||||||||||||||||||||||||||||||||||||
| debug bool | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // interpCacheEntry stores the build result. | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -206,10 +207,15 @@ func Gopt_Player_Gopx_OnCmd[T any](p *Player, handler func(cmd T) error) { | |||||||||||||||||||||||||||||||||||||
| return nil | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| return &SpxRunner{ | ||||||||||||||||||||||||||||||||||||||
| xgoCtx := xgobuild.NewContext(ctx) | ||||||||||||||||||||||||||||||||||||||
| xgoCtx.Importer = ctx.Importer | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+210
to
+211
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unused variable: The Recommendation: Either:
|
||||||||||||||||||||||||||||||||||||||
| runer := &SpxRunner{ | ||||||||||||||||||||||||||||||||||||||
| ctx: ctx, | ||||||||||||||||||||||||||||||||||||||
| debug: false, | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| runer.prebuildSSA() | ||||||||||||||||||||||||||||||||||||||
| return runer | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+210
to
+218
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are a few issues in this block that need to be addressed:
Here is a suggestion to fix these issues.
Suggested change
|
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Build builds the SPX code from the provided files object. | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -318,13 +324,17 @@ func (r *SpxRunner) Run(this js.Value, args []js.Value) any { | |||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // Release releases resources held by the SpxRunner. | ||||||||||||||||||||||||||||||||||||||
| func (r *SpxRunner) Release() { | ||||||||||||||||||||||||||||||||||||||
| // Clear context | ||||||||||||||||||||||||||||||||||||||
| r.ctx.RunContext = nil | ||||||||||||||||||||||||||||||||||||||
| if r.entry != nil && r.entry.interp != nil { | ||||||||||||||||||||||||||||||||||||||
| r.entry.interp.UnsafeRelease() | ||||||||||||||||||||||||||||||||||||||
| r.entry.fs.Close() | ||||||||||||||||||||||||||||||||||||||
| r.entry = nil | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| r.prebuildSSA() | ||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Performance concern: Calling Analysis:
Recommendation: Remove this call. SSA prebuilding should only happen once during initialization (as it does on line 217), not during cleanup. If re-prebuilding is needed, it should be done lazily before the next build operation, not during release. |
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func (r *SpxRunner) prebuildSSA() { | ||||||||||||||||||||||||||||||||||||||
| r.ctx.PrebuildSSA("github.com/goplus/spx/v2", "github.com/goplus/builder/tools/ai") | ||||||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The package paths |
||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+336
to
338
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing documentation: This new method lacks documentation explaining:
Suggestion: // prebuildSSA prebuilds SSA (Static Single Assignment) form for frequently-used packages
// to improve interpreter startup performance. This caches the compiled SSA representation
// of spx and ai packages, reducing build overhead for subsequent interpreter operations.
func (r *SpxRunner) prebuildSSA() {
r.ctx.PrebuildSSA("github.com/goplus/spx/v2", "github.com/goplus/builder/tools/ai")
} |
||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| func logWithCallerInfo(msg string, frame *ixgo.Frame) { | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused field: The
buildCtxfield is declared but never assigned or used anywhere in the code. This appears to be leftover from incomplete refactoring.Recommendation: Either remove this field entirely, or if it's intended for future use, add a comment explaining its purpose. If it should store the
xgoCtxcreated on line 210, the assignment is missing.