Re: [COMMIT] Increase READ_BUF_SIZE, used in #'insert-file-contents-internal, to #x10000
Aidan Kehoe <[email protected]>
| Newsgroups | gmane.emacs.xemacs.patches |
|---|---|
| Message-ID | <[email protected]> |
Ar an séú lá déag de mí Eanair, scríobh Jerry James: > On Thu, Jan 16, 2014 at 1:39 PM, Aidan Kehoe <[email protected]> wrote: > > > > -/* Stack sizes > 2**16 is a good way to elicit compiler bugs */ > > -/* #define READ_BUF_SIZE (2 << 16) */ > > -#define READ_BUF_SIZE (1 << 15) > > +#define READ_BUF_SIZE (2 << 16) > > > > (2 << 16) != 2**16 == #x10000. That would be (1 << 16); what you have > there is 2**17 == #x20000. That is an odd size for the original code! My mistake, indeed, though it works fine and is even better for my use case than #x10000. What about the following, since alloca_* is more careful about not blowing the stack, and its use shows better intentionality? (Though both buffers actually remain on the stack, with current thresholds.) diff -r 580ebed3500a src/fileio.c --- a/src/fileio.c Sat Jan 18 17:40:41 2014 +0100 +++ b/src/fileio.c Sat Jan 18 18:34:37 2014 +0000 @@ -1803,7 +1803,7 @@ { /* This function can call Lisp. GC checked 2000-07-28 ben */ int ifd, ofd, n; - Rawbyte buf[READ_BUF_SIZE]; + Rawbyte *buf = alloca_rawbytes (READ_BUF_SIZE); struct stat st, out_st; Lisp_Object handler; int speccount = specpdl_depth (); @@ -1909,7 +1909,7 @@ record_unwind_protect (close_file_unwind, ofd_locative); - while ((n = read_allowing_quit (ifd, buf, sizeof (buf))) > 0) + while ((n = read_allowing_quit (ifd, buf, READ_BUF_SIZE)) > 0) { if (write_allowing_quit (ofd, buf, n) != n) report_file_error ("I/O error", newname); @@ -2899,7 +2899,7 @@ struct gcpro gcpro1, gcpro2, gcpro3, gcpro4; Lisp_Object val; int total; - Ibyte read_buf[READ_BUF_SIZE]; + Ibyte *read_buf = alloca_ibytes (READ_BUF_SIZE); int mc_count; struct buffer *buf = current_buffer; Lisp_Object curbuf; @@ -3199,8 +3199,7 @@ Charcount cc_inserted, this_tell = last_tell; QUIT; - this_len = Lstream_read (XLSTREAM (stream), read_buf, - sizeof (read_buf)); + this_len = Lstream_read (XLSTREAM (stream), read_buf, READ_BUF_SIZE); if (this_len <= 0) { -- ‘Liston operated so fast that he once accidentally amputated an assistant’s fingers along with a patient’s leg, […] The patient and the assistant both died of sepsis, and a spectator reportedly died of shock, resulting in the only known procedure with a 300% mortality.’ (Atul Gawande, NEJM, 2012) _______________________________________________ XEmacs-Patches mailing list [email protected] http://lists.xemacs.org/mailman/listinfo/xemacs-patches