Re: CPU/Memory limiting



TongKe Xue wrote:
I think there is a misunderstanding.
My goal is not to enforce these limits at compile time.

My goal is to enforece these limits at run time.

You exceed the memory limit? I don't allow you to allocate more memory.
You exceed your cpu slice? I swap you out and run another thread for a
while.

As another poster pointed out, this is an operating-system-dependent
function, not one that belongs in a portable high-level language. So you
now need a system administrator to detect when a process is being a CPU
or memory hog and take some kind of action.

This is *exactly* what an OS does for a living! I don't know how to do
this on a Windows server, but on Linux and most other Unix-like systems,
there is a gizmo called "ulimit". This allows you to set a policy on how
big a process can get or how much total CPU time it can accumulate. The
bad news is that, as far as I know, when the process *does* violate its
ulimit, it is unceremoniously terminated and expunged from the system.
If that kind of behavior is compatible with your game, great. Otherwise,
you'll have to find a way to trap the ulimits and deal with them.

In any event, I think you're making this hard for yourself. There are
existing simulation game frameworks that work very well, and I think
there are even some with Ruby bindings. It sounds to me like you're
trying to reinvent some wheels rather than designing a user experience.
I'd recommend getting a good handle on the "whats" first before delving
much deeper into the "hows".

.



Relevant Pages

  • RE: Limiting cpu usage per process
    ... Ulimit doesn't actually cpu utilization so much as cpu time. ... given process to a value that is less than the total amount of memory ... > Regards, Marshall ...
    (RedHat)
  • Re: FC2 locked up when killing runaway process
    ... How did you kill this process and want user limits were in effect. ... What I suspect is that the process grew to use all memory ... began dumping core. ... with a shell wrapper or with ulimit() calls in the process. ...
    (Fedora)
  • Re: Vista
    ... The data path inside systems varies mssively from place to place. ... Typically,, the interface from the memory controller to the ... outside world will already be '128bit', but internally to the CPU, will ... The important 'point' about the address bus however, is that it limits how ...
    (alt.comp.periphs.mainboard.asus)
  • Re: Need advice on ORA-04030 and pga_aggregate_target parameter
    ... ulimit looks good and nothing is in the alert ... memory when trying to allocate 16396 bytes (koh-kghu call,pmuccst: ... can increase the limits in /etc/security/limits.conf, ... which will allow processes to allocate memory ...
    (comp.databases.oracle.server)
  • Re: [ckrm-tech] [RFC] Resource Management - Infrastructure choices
    ... guarantees cannot be met via limits. ... cpu to container Z. ... However, if Y does not use its share of the cpu, I would like the leftover cpu time to be made available to X and Z, in a ratio based on their allocated weights. ... I can see that with things like memory this could become tricky but for CPU I think it's a valid scenario. ...
    (Linux-Kernel)