Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/flutter_pty_unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,22 @@ typedef struct ReadLoopOptions

char *error_message = NULL;

// One read is one Dart port message, and each message costs a typed-data
// allocation, a stream event and the GC that follows. The read SIZE therefore
// decides throughput under heavy output far more than the byte count does: at
// 1 KB, 15 MB of output became ~15,000 messages and the isolate spent its time
// on message machinery instead of the terminal.
//
// read() returns as soon as any data is available and never waits to fill this,
// so an echoed keystroke still arrives in one small read — interactive latency
// is unaffected.
#define PTY_READ_BUFFER_SIZE (64 * 1024)

static void *read_loop(void *arg)
{
ReadLoopOptions *options = (ReadLoopOptions *)arg;

char buffer[1024];
char buffer[PTY_READ_BUFFER_SIZE];

while (1)
{
Expand Down
6 changes: 5 additions & 1 deletion src/flutter_pty_win.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,11 +161,15 @@ typedef struct ReadLoopOptions

} ReadLoopOptions;

// See the note in flutter_pty_unix.c — one read is one Dart port message, so the
// read size is what decides throughput under heavy output.
#define PTY_READ_BUFFER_SIZE (64 * 1024)

static DWORD WINAPI read_loop(LPVOID arg)
{
ReadLoopOptions *options = (ReadLoopOptions *)arg;

char buffer[1024];
char buffer[PTY_READ_BUFFER_SIZE];

while (1)
{
Expand Down