emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to set time limit and memory limit for execution of source blocks
@ 2020-02-04  6:40 Anoop GR
  2020-02-04  7:23 ` Tim Cross
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Anoop GR @ 2020-02-04  6:40 UTC (permalink / raw)
  To: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 417 bytes --]

Dear Emacs hackers,

Like all of you, I think orgmode is the best way to organise study notes.

I am solving competitive programming questions from Topcoder.com
There are strict guidelines on memory limit of 256MB and time limit of 2sec
for solutions

How do I enforce the same on my orgmode source blocks.
I want the execution to stop whenever it exceeds the above limits on memory
and time.

Long live Emacs,
Anoop

[-- Attachment #2: Type: text/html, Size: 632 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to set time limit and memory limit for execution of source blocks
  2020-02-04  6:40 How to set time limit and memory limit for execution of source blocks Anoop GR
@ 2020-02-04  7:23 ` Tim Cross
  2020-02-05  5:16 ` stardiviner
  2020-02-09 14:54 ` Ken Mankoff
  2 siblings, 0 replies; 5+ messages in thread
From: Tim Cross @ 2020-02-04  7:23 UTC (permalink / raw)
  To: emacs-orgmode


This is probably something which would need to be addressed in the
interpreter/compiler of the language you are using rather than within
Emacs or org-mode.

I would suspect that in your case, you are best off tangling the source
blocks to create separate executable scripts/code which you then run
outside of Emacs itself. Running the code blocks from within
org-mode/Emacs is going to adversely impact on the execution time (it
will be slower) and complicates/muddies calculation of memory usage (you
really only want to count the memory used by the child process running
your code, not that of Emacs).

Using tangled source code files will also allow you to use OS tools for
timing and memory metrics (depending on what platform your on).

If your source code blocks are emacs-lisp, things are a little
different. There will still be some overhead which may impact on
performance. I don't think you can easily identify memory useage (i.e.
memory used by your source code as opposed to memory used by Emacs for
everything else).

Anoop GR <anoopemacs@gmail.com> writes:

> Dear Emacs hackers,
>
> Like all of you, I think orgmode is the best way to organise study notes.
>
> I am solving competitive programming questions from Topcoder.com
> There are strict guidelines on memory limit of 256MB and time limit of 2sec
> for solutions
>
> How do I enforce the same on my orgmode source blocks.
> I want the execution to stop whenever it exceeds the above limits on memory
> and time.
>
> Long live Emacs,
> Anoop


--
Tim Cross

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to set time limit and memory limit for execution of source blocks
  2020-02-04  6:40 How to set time limit and memory limit for execution of source blocks Anoop GR
  2020-02-04  7:23 ` Tim Cross
@ 2020-02-05  5:16 ` stardiviner
  2020-02-09 14:54 ` Ken Mankoff
  2 siblings, 0 replies; 5+ messages in thread
From: stardiviner @ 2020-02-05  5:16 UTC (permalink / raw)
  To: emacs-orgmode


Anoop GR <anoopemacs@gmail.com> writes:

> Dear Emacs hackers,
>
> Like all of you, I think orgmode is the best way to organise study notes.
>
> I am solving competitive programming questions from Topcoder.com
> There are strict guidelines on memory limit of 256MB and time limit of 2sec for solutions
>
> How do I enforce the same on my orgmode source blocks.
> I want the execution to stop whenever it exceeds the above limits on memory and time.
>
> Long live Emacs,
> Anoop

Just an possible solution, use Emacs advice on org-babel-execute:<lang> to
modify the language execute command. Prepend with Linux commands which can limit
process resources.

-- 
[ stardiviner ]
       I try to make every word tell the meaning what I want to express.

       Blog: https://stardiviner.github.io/
       IRC(freenode): stardiviner, Matrix: stardiviner
       GPG: F09F650D7D674819892591401B5DF1C95AE89AC3
      

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to set time limit and memory limit for execution of source blocks
  2020-02-04  6:40 How to set time limit and memory limit for execution of source blocks Anoop GR
  2020-02-04  7:23 ` Tim Cross
  2020-02-05  5:16 ` stardiviner
@ 2020-02-09 14:54 ` Ken Mankoff
  2020-02-10  7:15   ` Anoop GR
  2 siblings, 1 reply; 5+ messages in thread
From: Ken Mankoff @ 2020-02-09 14:54 UTC (permalink / raw)
  To: Anoop GR; +Cc: emacs-orgmode

On 2020-02-03 at 22:40 -08, Anoop GR <anoopemacs@gmail.com> wrote...
> How do I enforce the same on my orgmode source blocks. I want the
> execution to stop whenever it exceeds the above limits on memory and
> time.

There are several packages that implement :async source blocks via the :async header arg. It seems like one of these could be fairly easy to adapt to monitor the process it spawns.

  -k.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How to set time limit and memory limit for execution of source blocks
  2020-02-09 14:54 ` Ken Mankoff
@ 2020-02-10  7:15   ` Anoop GR
  0 siblings, 0 replies; 5+ messages in thread
From: Anoop GR @ 2020-02-10  7:15 UTC (permalink / raw)
  To: Ken Mankoff; +Cc: emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 592 bytes --]

Thanks for the tip Ken.
I will get hold of one of those packages and modify it to my needs.


On Sun, Feb 9, 2020 at 8:24 PM Ken Mankoff <mankoff@gmail.com> wrote:

> On 2020-02-03 at 22:40 -08, Anoop GR <anoopemacs@gmail.com> wrote...
> > How do I enforce the same on my orgmode source blocks. I want the
> > execution to stop whenever it exceeds the above limits on memory and
> > time.
>
> There are several packages that implement :async source blocks via the
> :async header arg. It seems like one of these could be fairly easy to adapt
> to monitor the process it spawns.
>
>   -k.
>
>

[-- Attachment #2: Type: text/html, Size: 995 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-02-10  7:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-04  6:40 How to set time limit and memory limit for execution of source blocks Anoop GR
2020-02-04  7:23 ` Tim Cross
2020-02-05  5:16 ` stardiviner
2020-02-09 14:54 ` Ken Mankoff
2020-02-10  7:15   ` Anoop GR

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).