Remove reflection in pprint and cl-format to improve performance

Description

There are many occurrences of reflection in the pprint implementation.

By eliminating all of them, I ran one benchmark of pprint'ing a Clojure map that resulted in a 300 Kbyte output. After eliminating reflection, the elapsed time to pprint was reduced by 18% (about 14.0 sec down to about 11.5 sec) on a recent model MacBook Pro.

Patch: clj-1259-2.patch
Screened by: Alex Miller

Environment

None

Attachments

2
  • 09 Oct 2015, 02:59 PM
  • 10 Sep 2013, 05:36 AM

Activity

Show:

Andy Fingerhut October 17, 2015 at 12:41 PM

Michael, I have attached a minimal patch to https://clojure.atlassian.net/browse/CLJ-1827#icft=CLJ-1827 for the one reflection warning still in pretty_writer.clj.

I did not save a copy of your patch before Alex removed it from this ticket, so cannot create a patch similar to yours for CLJ-1827. If you attach your patch as is to CLJ-1827, I could look into updating it for latest master.

Alex Miller October 13, 2015 at 10:56 PM

I created https://clojure.atlassian.net/browse/CLJ-1827#icft=CLJ-1827 to track this - feel free to drop a patch there.

Andy Fingerhut October 13, 2015 at 8:11 PM

Michael, would you be interested in creating the ticket and creating the patch for it? If not, I can get to it in a week or two.

Alex Miller October 13, 2015 at 2:18 PM

Please create a new ticket for the new warning...

Andy Fingerhut October 13, 2015 at 5:07 AM

Michael, looks like that reflection warning is in code introduced after I wrote my patch. Now that the v2 patch has been committed, since it includes setting warn-on-reflection to true for the pretty_writer.clj source file, there is now that one reflection warning printed during builds of the latest master. Eliminating that warning might be enough motivation for the Clojure core team to get a fix for it into a later 1.8.0-beta, but of course that is their decision.

Completed

Details

Assignee

Reporter

Approval

Ok

Patch

Code

Priority

Affects versions

Fix versions

Created September 10, 2013 at 5:34 AM
Updated October 17, 2015 at 12:41 PM
Resolved October 17, 2015 at 12:41 PM