Skip to content

Conversation

mhinz
Copy link
Member

@mhinz mhinz commented Apr 14, 2015

Currently the logfile (":profile start {logfile}") only gets written when Vim
exits. This new command allows to dump the log immediately without exiting.

@marvim marvim added the RFC label Apr 14, 2015
@mhinz mhinz force-pushed the add-profile-dump branch from c6854a5 to c5683a2 Compare April 14, 2015 15:45
@splinterofchaos
Copy link

How do you make sure the profile doesn't get dumped twice?

@ZyX-I
Copy link
Contributor

ZyX-I commented Apr 14, 2015

@splinterofchaos Why do you think this is needed? profile dump dumps intermediate (current) state, by the time NeoVim exits there may and probably will be some changes. Even if there are none (e.g. when using profile pause before profile dump) there is not much harm in overwriting file with the results with identical contents.

@mhinz
Copy link
Member Author

mhinz commented Apr 14, 2015

At exit it will be overwritten again. dump is mainly meant to get access to the log without restarting Vim.

I guess I could also add :profile stop while being at it. Yes/no?

@splinterofchaos
Copy link

there is not much harm in overwriting file with the results with identical contents.

Good point.

I guess I could also add :profile stop while being at it. Yes/no?

Maybe it's not as necessary as I thought, but if we want to give the user finer control over when to dump the profiling info, I think it also makes sense to let the user specify whether we should or not.

@mhinz mhinz changed the title [RFC] Add ":profile dump" [WIP] Add ":profile dump" Apr 14, 2015
@marvim marvim added WIP and removed RFC labels Apr 14, 2015
@mhinz mhinz force-pushed the add-profile-dump branch from c5683a2 to d24745c Compare April 15, 2015 00:16
@mhinz mhinz changed the title [WIP] Add ":profile dump" [RFC] Add ":profile dump" Apr 15, 2015
@marvim marvim added RFC and removed WIP labels Apr 15, 2015
} else if (STRCMP(eap->arg, "stop") == 0) {
profile_dump();
do_profiling = PROF_NONE;
set_vim_var_nr(VV_PROFILING, 0L);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering what will happen if you do profile start after profile stop? It should start new profiling, but AFAIR neither of profile_dump, set_vim_var is clearing the associated structures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I'll fix that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

profile_fname also needs to be freed.

@mhinz mhinz force-pushed the add-profile-dump branch 2 times, most recently from 143115f to 04e855e Compare April 16, 2015 11:19
@mhinz
Copy link
Member Author

mhinz commented Apr 16, 2015

I added static void profile_reset(void) for proper cleanup on calling :profile stop.

scriptitem_T *si;

for (int id = 1; id <= script_items.ga_len; id++) {
si = &SCRIPT_ITEM(id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

si should be declared here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected!

@mhinz mhinz force-pushed the add-profile-dump branch from 04e855e to 74a4181 Compare April 16, 2015 13:24
@splinterofchaos
Copy link

LGTM 👍

@mhinz mhinz force-pushed the add-profile-dump branch 2 times, most recently from 07514a8 to 96303c3 Compare April 16, 2015 18:39
@mhinz
Copy link
Member Author

mhinz commented Apr 16, 2015

The :profile stop command now resets all profiling information for sourced files and functions.

@@ -3,6 +3,47 @@

#include "nvim/profile.h"

// All user-defined functions are found in this hashtable.
hashtab_T func_hashtab;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be a declaration, like extern hashtab_T func_hashtab; and only be defined in one file (eval.c?).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is something we're changing, but the current convention I see is to use EXTERN (defined in nvim/globals.h), which initializes it when included from main.c.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@mhinz mhinz force-pushed the add-profile-dump branch 2 times, most recently from d0d10d9 to e17d195 Compare April 17, 2015 00:01
@mhinz
Copy link
Member Author

mhinz commented Apr 17, 2015

Uhm, what's the proper fix of:

/home/travis/build/neovim/neovim/src/nvim/eval.h:42:16: error: ‘dumuf’ defined but not used [-Werror=unused-variable]
cc1: all warnings being treated as errors

Just making it non-static is probably the wrong approach. And I can't just use (void)dumuf in the file scope. And just throwing that in a random function seems wrong, too.

Maybe there's is another way where we don't have to use that dummy variable in the first place?

@mhinz mhinz force-pushed the add-profile-dump branch from d52d4ab to eb29a63 Compare April 17, 2015 00:47
@splinterofchaos
Copy link

Uhm, what's the proper fix of:

That's what extern does, but extern requires there be exactly one source file that actually defines the value (or just declares it without extern). That's what the macro EXTERN defines in globals.h does. (When included from main.c, there won't be an extern on the declaration.)

@mhinz mhinz force-pushed the add-profile-dump branch from eb29a63 to 1eafad4 Compare April 17, 2015 08:12
@mhinz
Copy link
Member Author

mhinz commented Apr 17, 2015

@splinterofchaos I guess I was a bit tired already, since I didn't see that it has to be extern unless the dummy variable was created in the macro itself. EXTERN is neat.

@mhinz mhinz force-pushed the add-profile-dump branch 2 times, most recently from 079952c to dc6868e Compare April 17, 2015 09:32
@mhinz
Copy link
Member Author

mhinz commented Apr 17, 2015

[...]
05:39:48,221 WARN  - /home/quickbuild/buildagent/workspace/root/neovim/pull-requests-automated/src/nvim/eval.c: In function ‘call_user_func’:
05:39:48,221 WARN  - /home/quickbuild/buildagent/workspace/root/neovim/pull-requests-automated/src/nvim/eval.c:19078:16: error: ‘call_start’ may be used uninitialized in this function [-Werror=uninitialized]
05:39:48,455 WARN  - cc1: all warnings being treated as errors
05:39:48,458 WARN  - make[3]: *** [src/nvim/CMakeFiles/nvim.dir/eval.c.o] Error 1
05:39:48,459 WARN  - make[2]: *** [src/nvim/CMakeFiles/nvim.dir/all] Error 2
05:39:48,459 WARN  - make[1]: *** [src/nvim/CMakeFiles/nvim.dir/rule] Error 2
05:39:48,459 WARN  - make: *** [nvim] Error 2
05:39:48,562 INFO  - Executing post-execute action...
05:39:48,562 ERROR - Step 'master>buildall>build-node?testNode=linux-64>build-and-run-tests>build-and-run-tests-parameterized?buildType=Release>configure-neovim-and-build-nvim' is failed: Failed to run command: mkdir -p build/Release && cd build/Release && cmake -G "Unix Makefiles" -DBUSTED_OUTPUT_TYPE=junit -DCMAKE_BUILD_TYPE=Release -DTRAVIS_CI_BUILD=ON ../.. && make nvim nvim-test unittest-headers tty-test
Command return code: 2
Command error output: /home/quickbuild/buildagent/workspace/root/neovim/pull-requests-automated/src/nvim/eval.c: In function ‘call_user_func’:
/home/quickbuild/buildagent/workspace/root/neovim/pull-requests-automated/src/nvim/eval.c:19078:16: error: ‘call_start’ may be used uninitialized in this function [-Werror=uninitialized]
cc1: all warnings being treated as errors
make[3]: *** [src/nvim/CMakeFiles/nvim.dir/eval.c.o] Error 1
make[2]: *** [src/nvim/CMakeFiles/nvim.dir/all] Error 2
make[1]: *** [src/nvim/CMakeFiles/nvim.dir/rule] Error 2
make: *** [nvim] Error 2
[...]

Why would http://neovim-qb.szakmeister.net/build/581 fail for me (this branch doesn't touch these functions) but not for other PRs?

@jszakmeister ^

@jszakmeister
Copy link
Contributor

There might be a couple of explanations. First, I recently changed the build steps to enable errors on warnings (just like the Travis build). The difference here is that the QB instance is also doing a full release build (without asserts) which may expose some things the Travis build (currently) does not. #2353 fixed several, but it appears there are a couple more. They either slid enable before I got things enabled, or I just missed them somehow (which is entirely possible--though I was pretty certain I ran a build everywhere to make sure it was clean before turning it on). So, I'd say ignore the error for this PR. Hopefully the remaining warnings can be fixed in short order (though someone else might have to step and do it since I'm at a conference for the next few days).

@mhinz
Copy link
Member Author

mhinz commented Apr 17, 2015

Okeydokey, thanks for the explanation. (And have fun at the conference!)

@mhinz mhinz changed the title [RFC] Add ":profile dump" [RFC] Add ":profile dump" and ":profile stop" Apr 17, 2015
@jszakmeister
Copy link
Contributor

BTW, the call_start bit should be fixed on master now. You'll need to rebase to bring it into your branch.

@mhinz mhinz force-pushed the add-profile-dump branch from dc6868e to 1ce98cf Compare April 24, 2015 08:56
@mhinz mhinz force-pushed the add-profile-dump branch 3 times, most recently from 9c42b2e to f31f29d Compare November 8, 2015 13:55
@mhinz mhinz changed the title [RFC] Add ":profile dump" and ":profile stop" [RDY] Add ":profile dump" and ":profile stop" Nov 8, 2015
@marvim marvim added RDY and removed RFC labels Nov 8, 2015
This adds two new tests for:

    :profile dump
    :profile stop
Currently the logfile (":profile start {logfile}") only gets written when Vim
exits. This new command allows to dump the log immediately without exiting.
This writes the logfile and stops profiling.
@mhinz mhinz merged commit 1902ee5 into neovim:master Nov 10, 2015
@jszakmeister jszakmeister removed the RDY label Nov 10, 2015
@mhinz mhinz deleted the add-profile-dump branch November 11, 2015 16:24
justinmk added a commit that referenced this pull request Dec 5, 2015
- shada/msgpack editor plugin #3270
- VimL Dict notifications #3603
    - Note: API for this feature may change.
- :profile dump, :profile stop #2427
- :oldfiles! #3611
- TermOpen, TermClose events #3653
- fix: shada/viminfo: Do not save unlisted and quickfix buffers #3581
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants