A computer-implemented method of setting operating system parameters of a device, the method comprising: monitoring, while the device executes an application, a state of the device based on a plurality of observable metrics of the device; identifying, based on the state of the device, at least one workload type from among a plurality of workload types produced by executing the application on the device; generating a workload-specific policy corresponding to the at least one workload type; and setting the operating system parameters based on the workload-specific policy; wherein the generating the workload-specific policy comprises: modifying a generic policy, the generic policy including a plurality of setting rules for setting parameters of the operating system based on the state of the device, wherein modifying the generic policy comprises selecting a setting rule associated with the at least one workload type from among the plurality of setting rules included in the generic policy, the generic policy comprising a default policy for setting parameters of the operating system; and generating the workload-specific policy based on the modified generic policy, the workload-specific policy including the selected setting rule of the plurality of setting rules of the generic policy; and iteratively refining the workload-specific policy by: computing a loss value, which is representing a performance degradation of the device when the workload-specific policy is applied instead of the generic policy is applied, comparing the loss value with a specific threshold, and modifying the workload-specific policy using an optimization algorithm based on the loss value, and wherein when the loss value is less than the specific threshold, the workload-specific policy is used for setting the operating system parameters of the device. monitoring, while the device executes an application, a state of the device based on a plurality of observable metrics of the device; identifying, based on the state of the device, at least one workload type from among a plurality of workload types produced by executing the application on the device; generating a workload-specific policy corresponding to the at least one workload type; and setting the operating system parameters based on the workload-specific policy; wherein the generating the workload-specific policy comprises: modifying a generic policy, the generic policy including a plurality of setting rules for setting parameters of the operating system based on the state of the device, wherein modifying the generic policy comprises selecting a setting rule associated with the at least one workload type from among the plurality of setting rules included in the generic policy, the generic policy comprising a default policy for setting parameters of the operating system; and generating the workload-specific policy based on the modified generic policy, the workload-specific policy including the selected setting rule of the plurality of setting rules of the generic policy; and iteratively refining the workload-specific policy by: computing a loss value, which is representing a performance degradation of the device when the workload-specific policy is applied instead of the generic policy is applied, comparing the loss value with a specific threshold, and modifying the workload-specific policy using an optimization algorithm based on the loss value, and wherein when the loss value is less than the specific threshold, the workload-specific policy is used for setting the operating system parameters of the device. modifying a generic policy, the generic policy including a plurality of setting rules for setting parameters of the operating system based on the state of the device, wherein modifying the generic policy comprises selecting a setting rule associated with the at least one workload type from among the plurality of setting rules included in the generic policy, the generic policy comprising a default policy for setting parameters of the operating system; and generating the workload-specific policy based on the modified generic policy, the workload-specific policy including the selected setting rule of the plurality of setting rules of the generic policy; and iteratively refining the workload-specific policy by: computing a loss value, which is representing a performance degradation of the device when the workload-specific policy is applied instead of the generic policy is applied, comparing the loss value with a specific threshold, and computing a loss value, which is representing a performance degradation of the device when the workload-specific policy is applied instead of the generic policy is applied, comparing the loss value with a specific threshold, and modifying the workload-specific policy using an optimization algorithm based on the loss value, and wherein when the loss value is less than the specific threshold, the workload-specific policy is used for setting the operating system parameters of the device.