Opened 2 years ago

Closed 21 months ago

#1219 closed enhancement (fixed)

read-char could be better optimized

Reported by: sjamaan Owned by:
Priority: major Milestone: 5.0
Component: scrutinizer Version: 4.9.x
Keywords: Cc:
Estimated difficulty:

Description

Currently, there are two issues with read-char:

  • It calls ##sys#read-char/port, which is itself a CPS procedure (consuming needless CPU cycles and stack). This will get rewritten in c-platform.scm to a direct call to ##sys#read-char/port with fixed argcount. Is omitting argcount check really that much faster? Why not rewrite it to the complete body of ##sys#read-char/port instead?
  • Equally important, the ##sys#check-input-port call in ##sys#read-char/port is not being specialized, even though there's an entry in types.db(!) This also causes an extra needless CPS call, because it can (and should) be inlined.

Once this is fixed, we should run the slatex, kernwyk-wc and kernwyk-cat benchmarks to see how much of an improvement this is.

Change History (4)

comment:1 Changed 2 years ago by sjamaan

  • Component changed from unknown to scrutinizer
  • Milestone changed from someday to 5.0
  • Type changed from defect to enhancement

comment:2 Changed 2 years ago by sjamaan

The reason this happens seems to be because redefinitions of core forms are not always specialized (and that's usually correct in user code). The definition of ##sys#check-input-port occurs somewhere at the top of library.scm, which means specialization of later uses is invalidated.

comment:3 Changed 2 years ago by sjamaan

See also #745

comment:4 Changed 21 months ago by sjamaan

  • Resolution set to fixed
  • Status changed from new to closed

This has been fixed by 5fcf890d6a724da6d7eac2f7beee19aa6832c80f + 6b33edffd9ecac963466afda388a7c49ffba0108 / a8f97697496856c2675964b5c3658276b8f33466 + a1a0ab93968ac26fb112c864398de73c2264b494.

Note: See TracTickets for help on using tickets.