Merge pull request #10855 from blueyed/out_data_decide_throttle

Revisit out_data_decide_throttle
This commit is contained in:
Daniel Hahler 2019-08-30 07:46:24 +02:00 committed by GitHub
commit 7d53887352
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 20 deletions

View File

@ -405,8 +405,11 @@ static bool out_data_decide_throttle(size_t size)
return false; return false;
} else if (!visit) { } else if (!visit) {
started = os_hrtime(); started = os_hrtime();
} else if (visit % 20 == 0) { } else {
uint64_t since = os_hrtime() - started; uint64_t since = os_hrtime() - started;
if (since < (visit * 0.1L * NS_1_SECOND)) {
return true;
}
if (since > (3 * NS_1_SECOND)) { if (since > (3 * NS_1_SECOND)) {
received = visit = 0; received = visit = 0;
return false; return false;
@ -415,12 +418,10 @@ static bool out_data_decide_throttle(size_t size)
visit++; visit++;
// Pulse "..." at the bottom of the screen. // Pulse "..." at the bottom of the screen.
size_t tick = (visit % 20 == 0) size_t tick = visit % 4;
? 3 // Force all dots "..." on last visit. pulse_msg[0] = (tick > 0) ? '.' : ' ';
: (visit % 4); pulse_msg[1] = (tick > 1) ? '.' : ' ';
pulse_msg[0] = (tick == 0) ? ' ' : '.'; pulse_msg[2] = (tick > 2) ? '.' : ' ';
pulse_msg[1] = (tick == 0 || 1 == tick) ? ' ' : '.';
pulse_msg[2] = (tick == 0 || 1 == tick || 2 == tick) ? ' ' : '.';
if (visit == 1) { if (visit == 1) {
msg_putchar('\n'); msg_putchar('\n');
} }

View File

@ -40,7 +40,6 @@ static void help(void)
puts(" 0: foo bar"); puts(" 0: foo bar");
puts(" ..."); puts(" ...");
puts(" 96: foo bar"); puts(" 96: foo bar");
puts(" shell-test REP_NODELAY N {text}");
puts(" shell-test INTERACT"); puts(" shell-test INTERACT");
puts(" Prints \"interact $ \" to stderr, and waits for \"exit\" input."); puts(" Prints \"interact $ \" to stderr, and waits for \"exit\" input.");
} }
@ -67,8 +66,7 @@ int main(int argc, char **argv)
if (argc >= 3) { if (argc >= 3) {
fprintf(stderr, "%s\n", argv[2]); fprintf(stderr, "%s\n", argv[2]);
} }
} else if (strcmp(argv[1], "REP") == 0 || } else if (strcmp(argv[1], "REP") == 0) {
strcmp(argv[1], "REP_NODELAY") == 0) {
if (argc != 4) { if (argc != 4) {
fprintf(stderr, "REP expects exactly 3 arguments\n"); fprintf(stderr, "REP expects exactly 3 arguments\n");
return 4; return 4;
@ -78,15 +76,10 @@ int main(int argc, char **argv)
fprintf(stderr, "Invalid count: %s\n", argv[2]); fprintf(stderr, "Invalid count: %s\n", argv[2]);
return 4; return 4;
} }
if (strcmp(argv[1], "REP_NODELAY") == 0) { for (int i = 0; i < count; i++) {
for (int i = 0; i < count; i++) { printf("%d: %s\n", i, argv[3]);
printf("%d: %s\n", i, argv[3]); fflush(stdout);
fflush(stdout); if (i % 100 == 0) {
}
} else {
for (int i = 0; i < count; i++) {
printf("%d: %s\n", i, argv[3]);
fflush(stdout);
usleep(1000); // Wait 1 ms (simulate typical output). usleep(1000); // Wait 1 ms (simulate typical output).
} }
} }

View File

@ -50,7 +50,7 @@ describe("shell command :!", function()
end) end)
it("throttles shell-command output greater than ~10KB", function() it("throttles shell-command output greater than ~10KB", function()
child_session.feed_data(":!"..nvim_dir.."/shell-test REP_NODELAY 30001 foo\n") child_session.feed_data(":!"..nvim_dir.."/shell-test REP 30001 foo\n")
-- If we observe any line starting with a dot, then throttling occurred. -- If we observe any line starting with a dot, then throttling occurred.
-- Avoid false failure on slow systems. -- Avoid false failure on slow systems.