Opened 9 years ago

Closed 6 years ago

#860 closed enhancement (wontfix)

C_in_stackp could be optimized

Reported by: felix winkelmann Owned by: felix winkelmann
Priority: minor Milestone:
Component: core libraries Version: 4.7.x
Keywords: C_in_stackp nursery GC Cc:
Estimated difficulty:

Description

There may be situations where an allocation in the nursery exceeds the current stack-limit - the limit is "soft", any the check whether the limit is reached does take place only in certain functions and only at the start of a generated C function. Coalescing of allocations and various other factors could create a situation where an object is allocated just slighly above the limit which would trigger a minor GC at the next check but may leave us with an object that is in the nursery but starts outside of the limits.

Also the use of C_stack_pointer_test is not necessary in this function - taking the address of a local would be more than sufficient.

Attachments (1)

inlined-checks.patch (4.8 KB) - added by sjamaan 6 years ago.
Inlined C_in_stackp and friends

Download all attachments as: .zip

Change History (7)

comment:1 Changed 9 years ago by felix winkelmann

Component: unknowncore libraries

comment:2 Changed 9 years ago by felix winkelmann

Priority: majorminor
Summary: C_in_stackp may be buggyC_in_stackp could be optimized
Type: defectenhancement

I think this is actually ok. Inlining the in-stack test would definitely be worthwhile, though, to reduce function call overhead during GC. (Joerg Wittenberger suggested this as well on chicken-hakcers)

comment:3 Changed 6 years ago by sjamaan

I've tried to change this, but it doesn't seem to make that much of a difference.

The benchmark differences look like noise to me:

sjamaan@yves% ~/chickens/test/bin/csi -s compare.scm benchmark-chicken-5-plain.log benchmark.log 
+---[1]:
|-> installation-prefix: /home/sjamaan/chickens/chicken-5
|-> csc-options: 
|-> repetitions: 10

+---[2]:
|-> installation-prefix: /home/sjamaan/chickens/chicken-5-inlined
|-> csc-options: 
|-> repetitions: 10

Displaying normalized results (larger numbers indicate better results)

Programs                   [1]       [2]
========================================
0_________________________1.00______1.00
binarytrees_______________1.00______1.01
boyer_____________________1.00______1.05
browse____________________1.04______1.00
conform___________________1.00______1.04
cpstak____________________1.00______1.07
ctak______________________1.00______1.09
dderiv____________________1.00______1.08
deriv_____________________1.00______1.03
destructive_______________1.00______1.00
div-iter__________________1.35______1.00
div-rec___________________1.00______1.10
dynamic___________________1.00______1.12
earley____________________1.00______1.04
fft_______________________1.00______1.07
fib_______________________1.00______1.04
fibc______________________1.00______1.03
fibfp_____________________1.03______1.00
fprint____________________1.00______1.00
fread_____________________1.00______1.06
gcbench___________________1.00______1.04
graphs____________________1.00______1.04
hanoi_____________________1.00______1.02
kanren____________________1.00______1.03
kernwyk-ackermann_________1.00______1.05
kernwyk-array_____________1.02______1.00
kernwyk-cat_______________1.01______1.00
kernwyk-string____________1.00______1.00
kernwyk-sum_______________1.00______1.01
kernwyk-tail______________1.00______1.29
kernwyk-wc________________1.00______1.03
knucleotide_______________1.00______1.01
lattice___________________1.00______1.04
maze______________________1.00______1.06
mazefun___________________1.00______1.00
mbrot_____________________1.00______1.00
nbody_____________________1.00______1.03
nboyer____________________1.00______1.09
nestedloop________________1.00______1.01
nfa_______________________1.01______1.00
nqueens___________________1.08______1.00
ntakl_____________________1.00______1.15
nucleic2__________________1.00______1.04
paraffins_________________1.00______1.14
parsing___________________1.00______1.01
pnpoly____________________1.06______1.00
primes____________________1.00______1.04
psyntax___________________1.00______1.03
puzzle____________________1.00______1.13
ray_______________________1.01______1.00
ray2______________________1.00______1.04
sboyer____________________1.00______1.08
scheme____________________1.38______1.00
sieves-eratosthenes_______1.00______1.09
simplex___________________1.00______1.04
slatex____________________1.07______1.00
sort1_____________________1.00______1.05
tak_______________________1.02______1.00
takl______________________1.10______1.00
takr______________________1.00______1.00
traverse__________________1.02______1.00
travinit__________________1.07______1.00
triangl___________________1.00______1.03

I'll attach the patch I used.

comment:4 Changed 6 years ago by sjamaan

The main disadvantage I see in just going ahead and applying the patch is that it removes the ability to perform these checks in user code. However, as far as I can tell, there's not even a single egg out there that uses these checks.

comment:5 Changed 6 years ago by sjamaan

Results on x86 are only slightly better (the previous results were for x86-64):

+---[1]:
|-> installation-prefix: /home/sjamaan/chickens/chicken-5-plain
|-> csc-options: 
|-> repetitions: 10

+---[2]:
|-> installation-prefix: /home/sjamaan/chickens/chicken-5-inlined
|-> csc-options: 
|-> repetitions: 10

Displaying normalized results (larger numbers indicate better results)

Programs                   [1]       [2]
========================================
0_________________________1.00______1.00
binarytrees_______________1.00______1.17
boyer_____________________1.02______1.00
browse____________________1.00______1.01
conform___________________1.21______1.00
cpstak____________________1.00______1.05
ctak______________________1.00______1.00
dderiv____________________1.00______1.03
deriv_____________________1.00______1.00
destructive_______________1.00______1.04
div-iter__________________1.02______1.00
div-rec___________________1.79______1.00
dynamic___________________1.01______1.00
earley____________________1.00______1.00
fft_______________________1.04______1.00
fib_______________________1.00______1.00
fibc______________________1.00______1.05
fibfp_____________________1.00______1.00
fprint____________________1.04______1.00
fread_____________________1.00______1.05
gcbench___________________1.01______1.00
graphs____________________1.08______1.00
hanoi_____________________1.00______1.00
kanren____________________1.00______1.05
kernwyk-ackermann_________1.00______1.01
kernwyk-array_____________1.00______1.03
kernwyk-cat_______________1.10______1.00
kernwyk-string____________1.00______1.06
kernwyk-sum_______________1.01______1.00
kernwyk-tail______________1.00______1.05
kernwyk-wc________________1.00______1.05
knucleotide_______________1.00______1.00
lattice___________________1.00______1.01
maze______________________1.00______1.09
mazefun___________________1.00______1.02
mbrot_____________________1.00______1.00
nbody_____________________1.00______1.00
nboyer____________________1.00______1.01
nestedloop________________1.00______1.05
nfa_______________________1.00______1.02
nqueens___________________1.00______1.02
ntakl_____________________1.00______1.04
nucleic2__________________1.00______1.02
paraffins_________________1.00______1.07
parsing___________________1.00______1.06
pnpoly____________________1.00______1.04
primes____________________1.02______1.00
psyntax___________________1.00______1.00
puzzle____________________1.00______1.01
ray_______________________1.04______1.00
ray2______________________1.00______1.00
sboyer____________________1.00______1.02
scheme____________________1.00______1.00
sieves-eratosthenes_______1.02______1.00
simplex___________________1.00______1.00
slatex____________________1.00______1.07
sort1_____________________1.08______1.00
tak_______________________1.00______1.04
takl______________________1.00______1.02
takr______________________1.00______1.04
traverse__________________1.00______1.00
travinit__________________1.00______1.32
triangl___________________1.00______1.01

Changed 6 years ago by sjamaan

Attachment: inlined-checks.patch added

Inlined C_in_stackp and friends

comment:6 Changed 6 years ago by sjamaan

Resolution: wontfix
Status: newclosed

This is not a worthwhile change. Felix agrees.

Note: See TracTickets for help on using tickets.