12
12
// See the License for the specific language governing permissions and
13
13
// limitations under the License.
14
14
15
- use std:: sync:: atomic:: { AtomicU64 , Ordering } ;
15
+ use std:: sync:: atomic:: AtomicU64 ;
16
16
use std:: sync:: Arc ;
17
+ #[ cfg( target_os = "linux" ) ]
17
18
use std:: time:: Duration ;
18
19
19
20
use risingwave_batch:: task:: BatchManager ;
21
+ #[ cfg( target_os = "linux" ) ]
20
22
use risingwave_common:: util:: epoch:: Epoch ;
21
23
use risingwave_stream:: executor:: monitor:: StreamingMetrics ;
22
24
use risingwave_stream:: task:: LocalStreamManager ;
23
25
#[ cfg( target_os = "linux" ) ]
24
26
use tikv_jemalloc_ctl:: { epoch as jemalloc_epoch, stats as jemalloc_stats} ;
27
+ #[ cfg( target_os = "linux" ) ]
25
28
use tracing;
26
29
27
30
/// When `enable_managed_cache` is set, compute node will launch a [`GlobalMemoryManager`] to limit
28
31
/// the memory usage.
32
+ #[ cfg_attr( not( target_os = "linux" ) , expect( dead_code) ) ]
29
33
pub struct GlobalMemoryManager {
30
34
/// All cached data before the watermark should be evicted.
31
35
watermark_epoch : Arc < AtomicU64 > ,
@@ -39,7 +43,9 @@ pub struct GlobalMemoryManager {
39
43
pub type GlobalMemoryManagerRef = Arc < GlobalMemoryManager > ;
40
44
41
45
impl GlobalMemoryManager {
46
+ #[ cfg( target_os = "linux" ) ]
42
47
const EVICTION_THRESHOLD_AGGRESSIVE : f64 = 0.9 ;
48
+ #[ cfg( target_os = "linux" ) ]
43
49
const EVICTION_THRESHOLD_GRACEFUL : f64 = 0.7 ;
44
50
45
51
pub fn new (
@@ -63,7 +69,10 @@ impl GlobalMemoryManager {
63
69
self . watermark_epoch . clone ( )
64
70
}
65
71
72
+ #[ cfg( target_os = "linux" ) ]
66
73
fn set_watermark_time_ms ( & self , time_ms : u64 ) {
74
+ use std:: sync:: atomic:: Ordering ;
75
+
67
76
let epoch = Epoch :: from_physical_time ( time_ms) . 0 ;
68
77
let watermark_epoch = self . watermark_epoch . as_ref ( ) ;
69
78
watermark_epoch. store ( epoch, Ordering :: Relaxed ) ;
0 commit comments