Skip to content

Unlink blocks GC finalisation #2091

@Ngoguey42

Description

@Ngoguey42

A solution to lift that waiting time would be to run the unlinking inside an Stdlib.Thread.t. We would then have to be smart about when joining the thread.

In my test

Sys.remove file1;

Takes ~0.6 second

Sys.remove file1;
Unix.sleepf 1.;

Takes ~1.6 second

let thread = Thread.create (fun () -> Sys.remove file1) () in
Unix.sleepf 1.;
Thread.join thread;

Takes ~1.0 second


Additionally, I ran some benchmarks in order to give insight on why unlinking takes time.

I'm dumping the data here. I might come back later to do an analysis of these number.

The code and data can be found there: https://github.com/tarides/irmin-scratch/tree/main/scripts/issue2091

stats in 1d

file_bytes
10000000       0.000835
31622776       0.001707
100000000      0.003727
316227766      0.013034
1000000000     0.038884
3162277660     0.127229
10000000000    0.472575
Name: avg_unlink_duration_wall, dtype: float64

hostname
bench-gc       0.062876
comanche       0.069641
ngoguey-mbp    0.149480
Name: avg_unlink_duration_wall, dtype: float64

ram_treatement
None                  0.180565
Purged                0.057162
Purged_and_touched    0.044269
Name: avg_unlink_duration_wall, dtype: float64

fsync
False    0.098770
True     0.089227
Name: avg_unlink_duration_wall, dtype: float64

remove_method
Sys_remove     0.089510
Unix_unlink    0.098487
Name: avg_unlink_duration_wall, dtype: float64

stats in 2d

Click me

file_bytes   hostname
10000000     bench-gc       0.001428
             comanche       0.000604
             ngoguey-mbp    0.000473
31622776     bench-gc       0.002597
             comanche       0.001669
             ngoguey-mbp    0.000854
100000000    bench-gc       0.005115
             comanche       0.004215
             ngoguey-mbp    0.001851
316227766    bench-gc       0.011639
             comanche       0.011584
             ngoguey-mbp    0.015879
1000000000   bench-gc       0.031586
             comanche       0.034126
             ngoguey-mbp    0.050941
3162277660   bench-gc       0.088451
             comanche       0.105496
             ngoguey-mbp    0.187741
10000000000  bench-gc       0.299315
             comanche       0.329790
             ngoguey-mbp    0.788621
Name: avg_unlink_duration_wall, dtype: float64

file_bytes   ram_treatement
10000000     None                  0.000829
             Purged                0.000711
             Purged_and_touched    0.000964
31622776     None                  0.002610
             Purged                0.000826
             Purged_and_touched    0.001684
100000000    None                  0.007769
             Purged                0.001119
             Purged_and_touched    0.002292
316227766    None                  0.026737
             Purged                0.006621
             Purged_and_touched    0.005744
1000000000   None                  0.085077
             Purged                0.018401
             Purged_and_touched    0.013175
3162277660   None                  0.261826
             Purged                0.065951
             Purged_and_touched    0.053910
10000000000  None                  0.879107
             Purged                0.306503
             Purged_and_touched    0.232116
Name: avg_unlink_duration_wall, dtype: float64

file_bytes   fsync
10000000     False    0.000822
             True     0.000848
31622776     False    0.001715
             True     0.001698
100000000    False    0.003755
             True     0.003699
316227766    False    0.013298
             True     0.012769
1000000000   False    0.040523
             True     0.037246
3162277660   False    0.130572
             True     0.123886
10000000000  False    0.500706
             True     0.444445
Name: avg_unlink_duration_wall, dtype: float64

file_bytes   remove_method
10000000     Sys_remove       0.000824
             Unix_unlink      0.000846
31622776     Sys_remove       0.001695
             Unix_unlink      0.001718
100000000    Sys_remove       0.003712
             Unix_unlink      0.003742
316227766    Sys_remove       0.013248
             Unix_unlink      0.012820
1000000000   Sys_remove       0.038752
             Unix_unlink      0.039017
3162277660   Sys_remove       0.123452
             Unix_unlink      0.131006
10000000000  Sys_remove       0.444888
             Unix_unlink      0.500263
Name: avg_unlink_duration_wall, dtype: float64

hostname     ram_treatement
bench-gc     None                  0.168480
             Purged                0.010686
             Purged_and_touched    0.009461
comanche     None                  0.202387
             Purged                0.001236
             Purged_and_touched    0.005299
ngoguey-mbp  None                  0.170828
             Purged                0.159563
             Purged_and_touched    0.118048
Name: avg_unlink_duration_wall, dtype: float64

hostname     fsync
bench-gc     False    0.070231
             True     0.055521
comanche     False    0.076838
             True     0.062444
ngoguey-mbp  False    0.149242
             True     0.149717
Name: avg_unlink_duration_wall, dtype: float64

hostname     remove_method
bench-gc     Sys_remove       0.059108
             Unix_unlink      0.066644
comanche     Sys_remove       0.069591
             Unix_unlink      0.069690
ngoguey-mbp  Sys_remove       0.139831
             Unix_unlink      0.159128
Name: avg_unlink_duration_wall, dtype: float64

ram_treatement      fsync
None                False    0.193180
                    True     0.167951
Purged              False    0.057460
                    True     0.056863
Purged_and_touched  False    0.045671
                    True     0.042868
Name: avg_unlink_duration_wall, dtype: float64

ram_treatement      remove_method
None                Sys_remove       0.173600
                    Unix_unlink      0.187530
Purged              Sys_remove       0.049868
                    Unix_unlink      0.064456
Purged_and_touched  Sys_remove       0.045062
                    Unix_unlink      0.043477
Name: avg_unlink_duration_wall, dtype: float64

fsync  remove_method
False  Sys_remove       0.095333
       Unix_unlink      0.102207
True   Sys_remove       0.083687
       Unix_unlink      0.094768
Name: avg_unlink_duration_wall, dtype: float64

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions