Skip to content

Commit

Permalink
fix O(n^2) length calls in compact-ir lowering step (#50756)
Browse files Browse the repository at this point in the history
This can be a problem for very long function bodies.
  • Loading branch information
JeffBezanson authored Aug 2, 2023
1 parent 33e3d9f commit 3c64bc3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -4980,6 +4980,7 @@ f(x) = yt(x)
(let ((code '(block))
(locs '(list))
(linetable '(list))
(linetablelen 0)
(labltable (table))
(ssavtable (table))
(current-loc 0)
Expand All @@ -4992,6 +4993,7 @@ f(x) = yt(x)
(if (and (null? (cdr linetable))
(not (and (pair? e) (eq? (car e) 'meta))))
(begin (set! linetable (cons (make-lineinfo name file line) linetable))
(set! linetablelen (+ linetablelen 1))
(set! current-loc 1)))
(set! code (cons e code))
(set! i (+ i 1))
Expand All @@ -5013,13 +5015,15 @@ f(x) = yt(x)
(make-lineinfo name current-file current-line)
(make-lineinfo name current-file current-line (caar locstack)))
linetable))
(set! current-loc (- (length linetable) 1)))))
(set! linetablelen (+ linetablelen 1))
(set! current-loc linetablelen))))
((and (length> e 2) (eq? (car e) 'meta) (eq? (cadr e) 'push_loc))
(set! locstack (cons (list current-loc current-line current-file) locstack))
(set! current-file (caddr e))
(set! current-line 0)
(set! linetable (cons (make-lineinfo name current-file current-line current-loc) linetable))
(set! current-loc (- (length linetable) 1)))
(set! linetablelen (+ linetablelen 1))
(set! current-loc linetablelen))
((and (length= e 2) (eq? (car e) 'meta) (eq? (cadr e) 'pop_loc))
(let ((l (car locstack)))
(set! locstack (cdr locstack))
Expand Down

8 comments on commit 3c64bc3

@maleadt
Copy link
Member

@maleadt maleadt commented on 3c64bc3 Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to try out some Nanosoldier.jl stuff here, sorry for the noise.

@nanosoldier runtests(["JSON", "Crayons"], vs = "@f00957bf6f33f589577dbff903e0dd64b4a6b152")

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package evaluation job you requested has completed - no new issues were detected.
The full report is available.

@maleadt
Copy link
Member

@maleadt maleadt commented on 3c64bc3 Aug 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@LilithHafner That output doesn't look great; both the 0000-12-03 to 0001-01-01 and the Markdown rendering. How did you render the output shown in the PR?

I'm going to revert the change for now, as I'll be AFK for a couple of days.

@LilithHafner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanosoldier runtests(["JSON", "Crayons"], vs = "@f00957bf6f33f589577dbff903e0dd64b4a6b152")

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package evaluation job you requested has completed - no new issues were detected.
The full report is available.

@LilithHafner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vtjnash
Copy link
Member

@vtjnash vtjnash commented on 3c64bc3 Aug 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here.

Please sign in to comment.