compiler-explorer / compiler-explorer

Run compilers interactively from your web browser and interact with the assembly
https://godbolt.org/
BSD 2-Clause "Simplified" License
16.45k stars 1.75k forks source link

[REQUEST]: [Compiler API] Expose memory used amount #4422

Open DatabaseDropper opened 1 year ago

DatabaseDropper commented 1 year ago

Is your feature request related to a problem? Please describe

Hi,

I'd want to start with thank you for exposing Compiler API, it makes life easier when creating simple compilation related tools.

To the point - I'm using Compiler Explorer's API POST /api/compiler/<compiler-id>/compile from https://github.com/compiler-explorer/compiler-explorer/blob/main/docs/API.md

to compile user's programs

and I'm not exactly sure how can I obtain memory usage information, is it possible right now? or maybe it is limited to some languages/compilers?

Describe the solution you'd like

I'd expect to see memory related property in output json

"execResult": {
    "code": 0,
    "okToCache": true,
    "timedOut": false,
    "stdout": [
      {
        "text": "Hello World"
      }
    ],
    "stderr": [],
    "execTime": "495",
    "memoryUsedPeak": "150MB", // <------------ e.g this
    "processExecutionResultTime": 0.026739,
    "didExecute": true,
    "buildResult": {
      "inputFilename": "/tmp/compiler-explore...",
      "code": 0,
      "okToCache": true,
      "timedOut": false,
      "stdout": [],
      "stderr": [],
      "execTime": "6279",
      "processExecutionResultTime": 0.007463,
      "downloads": [],
    }
    ...
}

Describe alternatives you've considered

Well, the alternative for me is writing it myself :(

Additional context

Not applicable

jeremy-rifkin commented 1 year ago

Good idea, thanks for the request! I think it would be a bit tricky to implement but something might be possible with polling.

DatabaseDropper commented 1 year ago

@jeremy-rifkin

Hi, thank you for your response!

I know it sounds bad, but could you please let me know how much time such a thing would require? or whether there will be commitment at all?

I'm asking because I have to either wait for this patch or switch to other compilation APIs if it'd be longer than 1 month

Cheers

AbrilRBS commented 1 year ago

Hi! We understand that you're under some time contraint so I'll update you on the progress of this issue: We have looked at using pidusage-tree for getting the memory used for each compilation we execute, but so far we haven't been able to make it work, nor integrate it in the codebase in a satisfatory way.

So for now we're looking for other alternatives, although there seems to be nothing available that quite fits our usecase, so we might be a bit stuck