# No size classes.
init target-block-size=1000 block-size-threshold=90
----
low watermark: 900
high watermark: 1000
targetBoundary: 1000

should-flush size-before=800 size-after=900
----
should not flush

should-flush size-before=900 size-after=950
----
should not flush

should-flush size-before=900 size-after=1000
----
should not flush

should-flush size-before=900 size-after=1001
----
should flush

should-flush size-before=899 size-after=10000
----
should not flush

# Size classes. Note that the block allocation overhead is 360.
init target-block-size=800 size-class-aware-threshold=60 size-classes=(820, 1020, 1320, 1820)
----
low watermark: 480
high watermark: 952
targetBoundary: 652

# Should not flush when the "after" block fits in the same size class.
should-flush size-before=600 size-after=650
----
should not flush

# Should flush when the "after" block leads to more fragmentation in the next
# size class.
should-flush size-before=600 size-after=750
----
should flush

# Should not flush when the "after" block leads to less fragmentation in another
# size class.
should-flush size-before=600 size-after=950
----
should not flush

should-flush size-before=600 size-after=960
----
should flush

# Should flush when the after size is above the high watermark.
should-flush size-before=600 size-after=1500
----
should flush

# Should not flush when the "before" size is below the low watermark (even when
# the "after" size is greater than the high watermark).
should-flush size-before=400 size-after=1500
----
should not flush

# Size classes should be ignored when they're all above the target block size.
init target-block-size=1000 size-class-aware-threshold=60 size-classes=(1500, 2000, 2500)
----
low watermark: 900
high watermark: 1000
targetBoundary: 1000

# Size classes should be ignored when they're all below the target block size.
init target-block-size=1000 size-class-aware-threshold=60 size-classes=(500, 800, 900)
----
low watermark: 900
high watermark: 1000
targetBoundary: 1000

# Test with jemalloc boundaries.
init target-block-size=32768 jemalloc-size-classes
----
low watermark: 19661
high watermark: 40592
targetBoundary: 32400

# We should not flush until exceeding the boundary.
should-flush size-before=30000 size-after=31000
----
should not flush

# We should flush to avoid exceeding the boundary.
should-flush size-before=32000 size-after=32766
----
should flush

# We should not flush since we waste less space against the 40KiB boundary.
should-flush size-before=30000 size-after=39000
----
should not flush

# We should flush even if we would waste less space against the 48KiB boundary
# (it's not the first boundary after the target size).
should-flush size-before=39000 size-after=48500
----
should flush
