lang: Improve graph shape with speculative execution

Most of the time, we don't need to have a dynamic call sub graph, since
the actual function call could be represented statically as it
originally was before lambda functions were implemented. Simplifying the
graph shape has important performance benefits in terms of both keep the
graph smaller (memory, etc) and in avoiding the need to run transactions
at runtime (speed) to reshape the graph.

Co-authored-by: Samuel Gélineau <gelisam@gmail.com>
This commit is contained in:
James Shubin
2025-03-17 02:31:01 -04:00
parent 9c9f2f558a
commit 37bb67dffd
139 changed files with 1871 additions and 262 deletions

View File

@@ -98,7 +98,10 @@ type PrintfFunc struct {
// String returns a simple name for this function. This is needed so this struct
// can satisfy the pgraph.Vertex interface.
func (obj *PrintfFunc) String() string {
return fmt.Sprintf("%s@%p", PrintfFuncName, obj) // be more unique!
if obj.Type != nil {
return fmt.Sprintf("%s: %s", PrintfFuncName, obj.Type)
}
return PrintfFuncName
}
// ArgGen returns the Nth arg name for this function.
@@ -295,7 +298,9 @@ func (obj *PrintfFunc) Info() *interfaces.Info {
// getting them from FuncInfer, and not from here. (During unification!)
return &interfaces.Info{
Pure: true,
Memo: false,
Memo: true,
Fast: true,
Spec: true,
Sig: obj.Type,
Err: obj.Validate(),
}
@@ -367,6 +372,9 @@ func (obj *PrintfFunc) Copy() interfaces.Func {
// Call this function with the input args and return the value if it is possible
// to do so at this time.
func (obj *PrintfFunc) Call(ctx context.Context, args []types.Value) (types.Value, error) {
if len(args) < 1 {
return nil, fmt.Errorf("not enough args")
}
format := args[0].Str()
values := []types.Value{}