Using Cassette to overdub just some methods

I’m working on developing a software that mesure performance of a julia program and i’m using cassette since i have to intercept function calls and modify them, the problem is that when i overdub a function it recursively overdub also the function that are native of the julia language but i just want to apply this on functions declared by the user. is this possible?

Please provide more information about what you are doing.

You can restrict the overdub to only working on certain types.
So you can define a custom type and restrict the overdub to that.

1 Like

for example in simple code like

function a()
    for x = 0:2000000000 end
end

function b()
    for y = 0:1900000000 end
end

function test(arg)
    arg = 1 + 1
end

function main()
    a()
    b()
    test(0)
    println("Done!")
end

i want cassette to overdub the functions a, b and test but not the call to the increment in the for loop.

Then you can make your own type and define + on that type, then overdub + only for that type.

1 Like

Maybe i didn’t explain my self properly, my goal is to create a package that iterates over all user defined functions in a julia source code (that i didn’t edit) and apply some behaviour to all those functions. My problem is that overdub is recursive and overdubs also the language defined function like add ecc… sorry for the misunderstanding

I am not very familiar with Cassette but isn’t the whole point that you overdub everything recursively so that you thread your “context” through the whole computation and can “inject” your specific hooks where you want. Where you don’t want to do anything special you just have a “no-op” overdub.

2 Likes

You will need to post the code that you used. Using ::typeof(a) in the overdub you can overdub any function called a. Using type annotations on the arguments of the function you can control which methods you overdub.

1 Like