Skip to content
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

sidestep readline when executing a script #703

Merged
merged 1 commit into from
May 19, 2018

Conversation

rolandwalker
Copy link
Contributor

Readline was causing major perf issues when interpreting a script, and inappropriately storing each script line in ~/.tig_history.

src/prompt.c Outdated
if (cmd && *cmd && !argv_from_string(argv, &argc, cmd)) {
report("Too many arguments");
return REQ_NONE;
}

if (!cmd || !*cmd) {
report_clear();
if (!is_script_executing())
report_clear();
Copy link
Owner

Choose a reason for hiding this comment

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

Is this conditional behavior needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, this part is not important.

@jonas
Copy link
Owner

jonas commented Jul 30, 2017

How much slower was it? Persistence in the user Tig history file is definitely a big.

@rolandwalker
Copy link
Contributor Author

rolandwalker commented Jul 31, 2017

The speed penalty depends on configuration and can be extreme:

$ touch ~/.inputrc
$ printf 'set blink-matching-paren on\n' >> ~/.inputrc
$ TIG_SCRIPT=<(printf ':echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:quit\n') /usr/bin/time ./src/tig
        2.70 real         0.09 user         0.05 sys
$ git checkout script-sidestep-readline && make > /dev/null
$ TIG_SCRIPT=<(printf ':echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:quit\n') /usr/bin/time ./src/tig
        0.17 real         0.08 user         0.04 sys

@rolandwalker rolandwalker force-pushed the script-sidestep-readline branch 6 times, most recently from 65facbe to 7a0be90 Compare August 4, 2017 11:26
@@ -127,6 +127,20 @@ prompt_default_handler(struct input *input, struct key *key)
}

static enum input_status
prompt_script_handler(struct input *input, struct key *key)
Copy link
Owner

Choose a reason for hiding this comment

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

I am not sure if defining this is actually necessary. read_prompt_incremental allows to pass a NULL handler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There might be a smarter way to do it, but the NULL handler doesn't recognize newlines.

@rolandwalker rolandwalker force-pushed the script-sidestep-readline branch 2 times, most recently from 2718278 to 14528e5 Compare August 15, 2017 14:40
@jonas jonas merged commit 0ace5cd into jonas:master May 19, 2018
@jonas
Copy link
Owner

jonas commented May 19, 2018

Thanks.

@rolandwalker rolandwalker deleted the script-sidestep-readline branch May 19, 2018 13:51
rolandwalker added a commit to rolandwalker/tig that referenced this pull request May 21, 2018
Readline was causing major perf issues when interpreting a script,
and inappropriately storing each script line in ~/.tig_history.
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.

2 participants