You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
The processHelper function currently employs tail recursion to avoid stack overflow, which is beneficial for stack safety. However, the current design has noticeable performance drawbacks when handling deeply nested structures, taking multiple seconds to process the example case.
Describe the solution you'd like
I suggest refactoring the processHelper function to use an iterative approach rather than a recursive one. This could potentially speed up the function's runtime performance, making it more efficient for handling deeply nested loops.
Additional context
Here is a Go code snippet to replicate the issue. When run, this test case takes multiple seconds to complete, signifying a need for optimization.
sd:=SimpleDoc{
Issuer: "google.com",
Info: "this is a cool document",
Nested: []SimpleDoc{},
}
cur:=sdfori:=0; i<4000; i++ {
k:=SimpleDoc{Issuer: "google.com", Info: fmt.Sprintf("this is a cooler nested doc %d", i), Nested: []SimpleDoc{cur}}
cur=k
}
// marshal cur to json blob, _:=json.Marshal(cur)
// create a document overflowDoc:= processor.Document{
Blob: blob,
Type: simpledoc.SimpleDocType,
Format: processor.FormatJSON,
}
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
The processHelper function currently employs tail recursion to avoid stack overflow, which is beneficial for stack safety. However, the current design has noticeable performance drawbacks when handling deeply nested structures, taking multiple seconds to process the example case.
Describe the solution you'd like
I suggest refactoring the processHelper function to use an iterative approach rather than a recursive one. This could potentially speed up the function's runtime performance, making it more efficient for handling deeply nested loops.
Additional context
Here is a Go code snippet to replicate the issue. When run, this test case takes multiple seconds to complete, signifying a need for optimization.
The text was updated successfully, but these errors were encountered: