Skip to content

Commit 3bc50c7

Browse files
authored
Support sticky immix (#48)
1 parent ff401f9 commit 3bc50c7

File tree

10 files changed

+194
-89
lines changed

10 files changed

+194
-89
lines changed

.github/scripts/ci-build.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ if [ $# -eq 0 ]
1010
fi
1111
# debug or release
1212
build_type=$1
13+
# plan to use
14+
plan=$2
1315

1416
# helloworld.jl
1517
HELLO_WORLD_JL=$BINDING_PATH/.github/scripts/hello_world.jl
@@ -21,7 +23,7 @@ if [ "$build_type" == "release" ]; then
2123
fi
2224

2325
cd $MMTK_JULIA_DIR/mmtk
24-
cargo build --features immix $build_args
26+
cargo build --features $plan $build_args
2527

2628
cd $JULIA_PATH
2729
# Clean first

.github/scripts/ci-test-stdlib.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ declare -a tests_to_skip=(
2020
declare -a tests_with_multi_workers=(
2121
"Pkg"
2222
)
23+
# These tests run with a single worker
24+
declare -a tests_with_single_worker=(
25+
"SparseArrays",
26+
"LinearAlgebra"
27+
)
2328

2429
stdlib_path=$JULIA_PATH/usr/share/julia/stdlib
2530

@@ -48,11 +53,17 @@ do
4853
fi
4954

5055
if [[ "${tests_with_multi_workers[@]}" =~ "$test" ]]; then
51-
echo "-> Run multi-threads"
56+
echo "-> Run multi threaded"
5257
ci_run_jl_test $test 2
5358
continue
5459
fi
5560

61+
if [[ "${tests_with_single_worker[@]}" =~ "$test" ]]; then
62+
echo "-> Run single threaded"
63+
ci_run_jl_test $test 1
64+
continue
65+
fi
66+
5667
ci_run_jl_test $test
5768
fi
5869
done

.github/workflows/binding-tests.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Test Julia Binding
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
gc_plan:
7+
required: true
8+
type: string
9+
10+
jobs:
11+
build-debug:
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Setup environments
16+
run: |
17+
./.github/scripts/ci-checkout.sh
18+
./.github/scripts/ci-setup.sh
19+
- name: Build Julia (Debug)
20+
run: |
21+
./.github/scripts/ci-build.sh debug ${{ inputs.gc_plan }}
22+
- name: Style check
23+
run: |
24+
./.github/scripts/ci-style.sh
25+
26+
build-test-other:
27+
runs-on: ubuntu-22.04
28+
timeout-minutes: 360
29+
steps:
30+
- uses: actions/checkout@v2
31+
- name: Setup environments
32+
run: |
33+
./.github/scripts/ci-checkout.sh
34+
./.github/scripts/ci-setup.sh
35+
- name: Build Julia (Release)
36+
run: |
37+
./.github/scripts/ci-build.sh release ${{ inputs.gc_plan }}
38+
- name: Test Julia
39+
run: |
40+
./.github/scripts/ci-test-other.sh
41+
42+
build-test-stdlib:
43+
runs-on: ubuntu-22.04
44+
timeout-minutes: 360
45+
steps:
46+
- uses: actions/checkout@v2
47+
- name: Setup environments
48+
run: |
49+
./.github/scripts/ci-checkout.sh
50+
./.github/scripts/ci-setup.sh
51+
- name: Build Julia (Release)
52+
run: |
53+
./.github/scripts/ci-build.sh release ${{ inputs.gc_plan }}
54+
- name: Test Julia
55+
run: |
56+
./.github/scripts/ci-test-stdlib.sh

.github/workflows/ci.yml

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -12,49 +12,11 @@ concurrency:
1212
cancel-in-progress: true
1313

1414
jobs:
15-
build-debug:
16-
runs-on: ubuntu-22.04
17-
steps:
18-
- uses: actions/checkout@v2
19-
- name: Setup environments
20-
run: |
21-
./.github/scripts/ci-checkout.sh
22-
./.github/scripts/ci-setup.sh
23-
- name: Build Julia (Debug)
24-
run: |
25-
./.github/scripts/ci-build.sh debug
26-
- name: Style check
27-
run: |
28-
./.github/scripts/ci-style.sh
29-
30-
build-test-other:
31-
runs-on: ubuntu-22.04
32-
timeout-minutes: 360
33-
steps:
34-
- uses: actions/checkout@v2
35-
- name: Setup environments
36-
run: |
37-
./.github/scripts/ci-checkout.sh
38-
./.github/scripts/ci-setup.sh
39-
- name: Build Julia (Release)
40-
run: |
41-
./.github/scripts/ci-build.sh release
42-
- name: Test Julia
43-
run: |
44-
./.github/scripts/ci-test-other.sh
45-
46-
build-test-stdlib:
47-
runs-on: ubuntu-22.04
48-
timeout-minutes: 360
49-
steps:
50-
- uses: actions/checkout@v2
51-
- name: Setup environments
52-
run: |
53-
./.github/scripts/ci-checkout.sh
54-
./.github/scripts/ci-setup.sh
55-
- name: Build Julia (Release)
56-
run: |
57-
./.github/scripts/ci-build.sh release
58-
- name: Test Julia
59-
run: |
60-
./.github/scripts/ci-test-stdlib.sh
15+
binding-tests:
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
gc_plan: [immix, stickyimmix]
20+
uses: ./.github/workflows/binding-tests.yml
21+
with:
22+
gc_plan: ${{ matrix.gc_plan }}

julia/mmtk_julia.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,8 @@ JL_DLLEXPORT void* get_stackbase(int16_t tid) {
725725
return ptls2->stackbase;
726726
}
727727

728+
const bool PRINT_OBJ_TYPE = false;
729+
728730
/**
729731
* Corresponds to the function mark_loop in the original Julia GC. It
730732
* dispatches MMTk work for scanning internal pointers for the object obj.
@@ -749,6 +751,7 @@ JL_DLLEXPORT void scan_julia_obj(jl_value_t* obj, closure_pointer closure, Proce
749751
};
750752

751753
if (vt == jl_simplevector_type) { // scanning a jl_simplevector_type object (inlining label `objarray_loaded` from mark_loop)
754+
if (PRINT_OBJ_TYPE) { printf("scan_julia_obj %p: simple vector\n", obj); fflush(stdout); }
752755
size_t l = jl_svec_len(obj);
753756
jl_value_t **data = jl_svec_data(obj);
754757
jl_value_t **objary_begin = data;
@@ -757,6 +760,7 @@ JL_DLLEXPORT void scan_julia_obj(jl_value_t* obj, closure_pointer closure, Proce
757760
process_edge(closure, objary_begin);
758761
}
759762
} else if (vt->name == jl_array_typename) { // scanning a jl_array_typename object
763+
if (PRINT_OBJ_TYPE) { printf("scan_julia_obj %p: array\n", obj); fflush(stdout); }
760764
jl_array_t *a = (jl_array_t*)obj;
761765
jl_array_flags_t flags = a->flags;
762766

@@ -840,6 +844,7 @@ JL_DLLEXPORT void scan_julia_obj(jl_value_t* obj, closure_pointer closure, Proce
840844
return;
841845
}
842846
} else if (vt == jl_module_type) { // inlining label `module_binding` from mark_loop
847+
if (PRINT_OBJ_TYPE) { printf("scan_julia_obj %p: module\n", obj); fflush(stdout); }
843848
jl_module_t *m = (jl_module_t*)obj;
844849
jl_svec_t *bindings = jl_atomic_load_relaxed(&m->bindings);
845850
jl_binding_t **table = (jl_binding_t**)jl_svec_data(bindings);
@@ -851,11 +856,15 @@ JL_DLLEXPORT void scan_julia_obj(jl_value_t* obj, closure_pointer closure, Proce
851856
if (b == (jl_binding_t*)jl_nothing)
852857
continue;
853858

859+
if (PRINT_OBJ_TYPE) { printf(" - scan table: %p\n", begin); fflush(stdout); }
854860
process_edge(closure, begin);
855861
}
856862

863+
if (PRINT_OBJ_TYPE) { printf(" - scan parent: %p\n", &m->parent); fflush(stdout); }
857864
process_edge(closure, &m->parent);
865+
if (PRINT_OBJ_TYPE) { printf(" - scan bindingkeyset: %p\n", &m->bindingkeyset); fflush(stdout); }
858866
process_edge(closure, &m->bindingkeyset);
867+
if (PRINT_OBJ_TYPE) { printf(" - scan bindings: %p\n", &m->bindings); fflush(stdout); }
859868
process_edge(closure, &m->bindings);
860869

861870
size_t nusings = m->usings.len;
@@ -865,6 +874,7 @@ JL_DLLEXPORT void scan_julia_obj(jl_value_t* obj, closure_pointer closure, Proce
865874

866875
for (; objary_begin < objary_end; objary_begin += 1) {
867876
jl_value_t *pnew_obj = *objary_begin;
877+
if (PRINT_OBJ_TYPE) { printf(" - scan usings: %p\n", objary_begin); fflush(stdout); }
868878
process_edge(closure, pnew_obj);
869879
}
870880
}
@@ -886,8 +896,10 @@ JL_DLLEXPORT void scan_julia_obj(jl_value_t* obj, closure_pointer closure, Proce
886896
process_edge(closure, slot);
887897
}
888898
} else if (vt == jl_string_type) { // scanning a jl_string_type object
899+
if (PRINT_OBJ_TYPE) { printf("scan_julia_obj %p: string\n", obj); fflush(stdout); }
889900
return;
890901
} else { // scanning a jl_datatype object
902+
if (PRINT_OBJ_TYPE) { printf("scan_julia_obj %p: datatype\n", obj); fflush(stdout); }
891903
if (vt == jl_weakref_type) {
892904
return;
893905
}

mmtk/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mmtk/Cargo.toml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2018"
1010
[package.metadata.julia]
1111
# Our CI matches the following line and extract mmtk/julia. If this line is updated, please check ci yaml files and make sure it works.
1212
julia_repo = "https://github.com/mmtk/julia.git"
13-
julia_version = "eb407eb68ea976df72c8e1cd6ec8607ff8d98fa5"
13+
julia_version = "e7e43f11687e7db62dc18e90f3ab9b24099539fd"
1414

1515
[lib]
1616
crate-type = ["staticlib", "rlib", "dylib"]
@@ -28,8 +28,8 @@ lazy_static = "1.1"
2828
# These changes are safe:
2929
# - change branch
3030
# - change repo name
31-
# But other changes including adding/removing whitespaces in commented lines may break the CI.
32-
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "e309f9351dff9cd0c8f3f590002c6edafd158c82" }
31+
# But other changes including adding/removing whitespaces in commented lines may break the CI
32+
mmtk = { git = "https://github.com/mmtk/mmtk-core.git", rev = "7b06ead8bffc8a33b059919d440cb0b9812359b9" }
3333
# Uncomment the following to build locally
3434
# mmtk = { path = "../repos/mmtk-core" }
3535
log = {version = "0.4", features = ["max_level_trace", "release_max_level_off"] }
@@ -40,13 +40,16 @@ chrono = "*"
4040
# ykstackmaps = { git = "https://github.com/udesou/ykstackmaps.git", branch = "udesou-master", version = "*" }
4141

4242
[features]
43-
default = []
43+
default = ["mmtk/malloc_counted_size", "scan_obj_c", "mmtk/vm_space"]
44+
45+
# Plans
4446
nogc = []
45-
semispace = []
46-
gencopy = []
47-
pageprotect = []
48-
malloc_counted_size = ["mmtk/malloc_counted_size"]
49-
immix = ["malloc_counted_size", "mmtk/immix_non_moving", "mmtk/immix_smaller_block", "scan_obj_c", "mmtk/vm_space"]
50-
marksweep = ["malloc_counted_size", "scan_obj_c"]
47+
immix = ["non_moving_immix"]
48+
stickyimmix = ["non_moving_immix"]
49+
marksweep = []
50+
51+
# TODO remove this when we properly support moving
52+
non_moving_immix = ["mmtk/immix_non_moving", "mmtk/immix_smaller_block"]
53+
5154
# FIXME update and use rust object scanner as default for immix
5255
scan_obj_c = []

mmtk/api/mmtk.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,19 @@ extern bool is_mapped_address(void* addr);
5656
extern void modify_check(void* ref);
5757
extern int object_is_managed_by_mmtk(void* addr);
5858
extern void runtime_panic(void);
59+
extern void unreachable(void);
5960

6061
extern void mmtk_set_vm_space(void* addr, size_t size);
62+
extern void mmtk_immortal_region_post_alloc(void* addr, size_t size);
6163

6264
// Write barriers
6365
extern void mmtk_memory_region_copy(MMTk_Mutator mutator, void* src_obj, void* src_addr, void* dst_obj, void* dst_addr, size_t size);
6466
extern void mmtk_object_reference_write_post(MMTk_Mutator mutator, const void* src, const void* target);
65-
extern uint8_t mmtk_needs_write_barrier(void);
66-
67+
extern void mmtk_object_reference_write_slow(MMTk_Mutator mutator, const void* src, const void* target);
68+
extern const uint8_t MMTK_NEEDS_WRITE_BARRIER;
69+
extern const uint8_t NO_BARRIER;
70+
extern const uint8_t OBJECT_BARRIER;
71+
extern const void* MMTK_SIDE_LOG_BIT_BASE_ADDRESS;
6772
/**
6873
* Tracing
6974
*/
@@ -121,7 +126,7 @@ extern void gc_init(long long min_heap_size, long long max_heap_size, Julia_Upca
121126
extern bool will_never_move(void* object);
122127
extern bool process(char* name, char* value);
123128
extern void scan_region(void);
124-
extern void handle_user_collection_request(void *tls);
129+
extern void handle_user_collection_request(void *tls, uint8_t collection);
125130
extern void initialize_collection(void* tls);
126131
extern void enable_collection(void);
127132
extern void disable_collection(void);

0 commit comments

Comments
 (0)