emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: process.c: read_process_output: hard coded 4096 bytes read limit


From: Paul Eggert
Subject: Re: process.c: read_process_output: hard coded 4096 bytes read limit
Date: Sat, 22 Jun 2013 10:27:55 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6

On 06/22/13 03:05, Miguel Guedes wrote:

> In process.c, function read_process_output, all reads are limited to a 
> maximum of 4096 bytes.  What is the rationale behind imposing a hardcoded 
> limit of 4096 bytes per read from a process channel? (why isn't the 
> user allowed to specify this read limit when creating a process/
> connection?)

I don't know, and that limit has bothered me in the past, too.

It's a simple matter to increase it to 16 K bytes; does the
patch below help your performance?  If so, I can install it.
Letting the user specify a larger limit
might make sense, but would take a bit of thought and hacking.

=== modified file 'src/coding.h'
--- src/coding.h        2013-05-22 14:53:21 +0000
+++ src/coding.h        2013-06-22 16:53:36 +0000
@@ -399,6 +399,7 @@
   int rejected;
 };
 
+enum { CARRYOVER_BYTES_MAX = 64 };
 
 struct coding_system
 {
@@ -491,7 +492,7 @@
   /* Set to 1 if charbuf contains an annotation.  */
   unsigned annotated : 1;
 
-  unsigned char carryover[64];
+  unsigned char carryover[CARRYOVER_BYTES_MAX];
   int carryover_bytes;
 
   int default_char;

=== modified file 'src/process.c'
--- src/process.c       2013-06-22 16:43:39 +0000
+++ src/process.c       2013-06-22 17:08:46 +0000
@@ -4949,7 +4949,7 @@
    starting with our buffered-ahead character if we have one.
    Yield number of decoded characters read.
 
-   This function reads at most 4096 characters.
+   This function reads at most MAX_ALLOCA bytes.
    If you want to read all available subprocess output,
    you must call it repeatedly until it returns zero.
 
@@ -4959,16 +4959,16 @@
 static int
 read_process_output (Lisp_Object proc, register int channel)
 {
-  register ssize_t nbytes;
-  char *chars;
-  register struct Lisp_Process *p = XPROCESS (proc);
+  ssize_t nbytes;
+  char chars[MAX_ALLOCA];
+  struct Lisp_Process *p = XPROCESS (proc);
   struct coding_system *coding = proc_decode_coding_system[channel];
   int carryover = p->decoding_carryover;
-  int readmax = 4096;
+  verify (CARRYOVER_BYTES_MAX < sizeof chars);
+  int readmax = sizeof chars - carryover;
   ptrdiff_t count = SPECPDL_INDEX ();
   Lisp_Object odeactivate;
 
-  chars = alloca (carryover + readmax);
   if (carryover)
     /* See the comment above.  */
     memcpy (chars, SDATA (p->decoding_buf), carryover);





reply via email to

[Prev in Thread] Current Thread [Next in Thread]