Summary
C_in_stackp could be optimized
Metadata
- Id: 385481ac53416d059cc08a66c8291b7abffb67be
- Trac id: 860
- Type: enhancement
- Reporter: felix
- Owner: felix
- Cc:
- Status: closed
- Component: core libraries
- Estimated difficulty:
- Resolution: wontfix
- Priority: minor
- Milestone:
- Version: 4.7.x
- Changetime: 2015-09-21 11:41:32 UTC
- Created: 2012-05-30 12:20:23 UTC
- Keywords: C_in_stackp nursery GC
Attachments
- 385481ac53416d059cc08a66c8291b7abffb67be/attachments/inlined-checks.patch
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.
Changes and comments
[2012-05-30 12:21:48 UTC] felix changed component from unknown to core libraries
[2012-06-03 18:21:52 UTC] felix changed priority from major to minor
[2012-06-03 18:21:52 UTC] felix changed type from defect to enhancement
[2012-06-03 18:21:52 UTC] felix changed summary
[2012-06-03 18:21:52 UTC] felix wrote:
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`)
[2015-09-20 16:44:12 UTC] sjamaan wrote:
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.
[2015-09-20 17:23:27 UTC] sjamaan wrote:
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.
[2015-09-20 19:15:06 UTC] sjamaan wrote:
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
[2015-09-20 19:19:09 UTC] sjamaan attached inlined-checks.patch (description=Inlined C_in_stackp and friends )
[2015-09-21 11:41:32 UTC] sjamaan changed status from new to closed
[2015-09-21 11:41:32 UTC] sjamaan set resolution to wontfix
[2015-09-21 11:41:32 UTC] sjamaan wrote:
This is not a worthwhile change. Felix agrees.