Skip to content

Commit

Permalink
buffer more reads from a boot-file file descriptor (#769)
Browse files Browse the repository at this point in the history
Without this additional buffering, loading boot files can trigger
thousands of small reads to parse a boot file. Introducing buffering
earlier in the process to reduce the number of those `read` system
calls to between 100 and 200.

The difference in startup time turns out to be very small on Linux and
macOS --- just a a couple of milliseconds, if anything. But buffering
is generally a good idea, and the change makes a startup system-call
trace look less suspicious.

In addition to buffering changes, this commit adds
`Sregister_boot_file_bytes`, so that an embedding application can
point to bytes that are already loaded into memory.
  • Loading branch information
mflatt authored Nov 30, 2023
1 parent 49c02dc commit 0702c8d
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 330 deletions.
12 changes: 9 additions & 3 deletions c/externs.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,23 +117,29 @@ extern void S_phantom_bytevector_adjust(ptr ph, uptr new_sz);
extern void S_fasl_init(void);
extern ptr S_fasl_read(INT fd, IFASLCODE situation, ptr path, ptr externals);
extern ptr S_bv_fasl_read(ptr bv, int ty, uptr offset, uptr len, ptr path, ptr externals);
extern ptr S_boot_read(INT fd, const char *path);
extern ptr S_boot_read(faslFile f, const char *path);
extern char *S_format_scheme_version(uptr n);
extern char *S_lookup_machine_type(uptr n);
extern void S_set_code_obj(char *who, IFASLCODE typ, ptr p, iptr n,
ptr x, iptr o);
extern ptr S_get_code_obj(IFASLCODE typ, ptr p, iptr n, iptr o);
extern int S_fasl_stream_read(void *stream, octet *dest, iptr n);
extern int S_fasl_intern_rtd(ptr *x);
#ifdef X86_64
extern void x86_64_set_popcount_present(ptr code);
#endif
#ifdef PORTABLE_BYTECODE_SWAPENDIAN
extern void S_swap_dounderflow_header_endian(ptr code);
#endif
extern void S_fasl_init_fd(fileFaslFile ffo, ptr path, INT fd,
int buffer_mode, uptr size);
extern void S_fasl_init_bytes(faslFile ffo, ptr path, void *data, iptr len);
extern void S_fasl_init_bv(faslFile ffo, ptr path, ptr bv);
extern int S_fasl_bytein(faslFile f);
extern uptr S_fasl_uptrin(faslFile f, INT *bytes_consumed);
extern void S_fasl_bytesin(octet *s, iptr n, faslFile f);

/* vfasl.c */
extern ptr S_vfasl(ptr bv, void *stream, iptr offset, iptr len);
extern ptr S_vfasl(ptr bv, faslFile stream, iptr offset, iptr len);
extern ptr S_vfasl_to(ptr v);

/* flushcache.c */
Expand Down
Loading

0 comments on commit 0702c8d

Please sign in to comment.