-
Notifications
You must be signed in to change notification settings - Fork 236
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
[draft] top-level profiling #3431
base: development
Are you sure you want to change the base?
Conversation
576c69d
to
f0e5e93
Compare
Now there's very basic tabulated profiling data: i1 : profile(1+1)
o1 = 2
i2 : profileSummary
o2 = #run %time position
1 48.07 stdio:1:9-1:10
1 .47 stdio:1:8-1:9
1 .15 stdio:1:10-1:11
1 .0002s elapsed total The idea being that the keyword |
I'm actually more confused now. Maybe I don't need to revert all of bf16db9, but I'm confused about what is everything happening in that commit. |
I think I figured out what's going on. The documentation of FilePosition says:
But some of the methods treat the first pair as the focus point instead. |
which methods treat the first pair as the focus point? they shouldn't. By now the documentation is slightly obsolete in the sense that 3 elements should never occur. |
I'm not aware of this profiler so cannot judge how it is affected by the changes to positioning. I can only reiterate that now all code locations are made of three pieces (though the last is not displayed at the m2 level, and so one could in theory leave it out): starting position, end position, and "focus" position. The latter is at the moment only used as the location in the error message should an error occur. |
Based on my reading of your additions, you were treating the first pair as the focus point. See for instance here in M2/M2/Macaulay2/d/debugging.dd Lines 27 to 29 in b59eb20
I'll fix this in a PR. I think it resolves most of the issues I'm seeing, but I'm also wondering about your motivation behind |
sorry I should've been clearer on what I meant by first or last:
in this definition the first location is the focus location. Unfortunately it becomes the last location at the m2 level, hence the confusion. but I'm assuming you figured this out. |
ah yes, |
Why do you care about including the parenthesis in the location, if it's unnecessary anyway? Seems more efficient to optimize them away as soon as possible. |
dc827d7
to
0b116af
Compare
parentheses are usually there for a reason, and we should respect that. in the expression
the location should be the 5 lines, not just the one in the middle. |
0b116af
to
b5dbb49
Compare
What are examples of good reasons for parentheses like this? |
b5dbb49
to
01db2c9
Compare
A lot of people will use parentheses like this, say to define a function. The whole purpose of my PR was to once and for all get the locations exactly right, instead of approximately right with lots of hacks (like randomly adding +1 to the final location to get that potential extra parenthesis). |
So to be precise, is this an explicit example of what you have in mind? f = (a,b,c) -> (
a+b+c
) In this case, the previous behavior cut out the closing parenthesis, and I agree with you that this is a good fix. But what about other instances of if x then (
error 0
) I would want the error position to point directly to |
yes, there's a benefit: otherwise the location of the |
How do you get the location of an |
it's a matter of principle. and yes, either using pseudocode, or using the debugger. |
01db2c9
to
e57d9f0
Compare
e57d9f0
to
8b79255
Compare
This PR is by no means ready, but I opened it for two reasons:
I'm fairly sure I have to revert @pzinn's bf16db9 which changes positions for lots of things, so I wanted to start the discussion now.Much lower priority, but for the first item above, there are several options: